Annoying behaviour of the != operator

Mahesh sutram at gmail.com
Wed Jun 8 14:01:27 EDT 2005


No, why should Python assume that if you use != without supplying a
__ne__ that this is what you want? Without direction it will compare
the two objects which is the default behavior.

So, s != t is True because the ids of the two objects are different.
The same applies to, for example s > t and s < t. Do you want Python to
be smart and deduce that you want to compare one variable within the
object if you don't create __gt__ and __lt__? I do not want Python to
do that.

Regards,
M




More information about the Python-list mailing list