Differences of "!=" operator behavior in python3 and python2 [ bug? ]

Dave Angel davea at davea.name
Mon May 13 19:22:24 EDT 2013


On 05/13/2013 06:53 PM, Mark Lawrence wrote:
> On 13/05/2013 22:17, Alister wrote:
>> On Mon, 13 May 2013 19:28:29 +0100, Fábio Santos wrote:
>>
>>> I think it is more readable. When doing more complicated statements I
>>> use != instead, but when it's a single test I prefer not … ==
>>>
>>> It's a personal thing. It may also have to do with the fact that I
>>> didn't know python had != when I was a novice.
>>> On 13 May 2013 19:08, "Ned Batchelder" <ned at nedbatchelder.com> wrote:
>>>
>>
>> I would then still write it as not (x == y) to make it clear to myself &
>> avoid any possible confusion although I think that X != Y is much
>> cleaner.
>> 2 lines from the zen stand out here:-
>>
>> Explicit is better than implicit.
>> in the face of ambiguity refuse the temptation to guess.
>>
>> there are many features of Python (& other languages) i did not now when
>> I started but have adopted once I understood what they were & how they
>> worked. then again use what you are most comfortable with.
>>
>> Practicality beats purity
>>
>
> I much prefer the alternative <> for != but some silly people insisted
> that this be removed from Python3.  Just how stupid can you get?
>

So which special methods should the <> operator call?  By rights it 
ought to call both __gt__ and __lt__ and return True if either of them 
is True.


-- 
DaveA



More information about the Python-list mailing list