Tuple assignment and generators?

Diez B. Roggisch deets at nospam.web.de
Fri May 5 11:23:02 CEST 2006


vdrab wrote:

>> beasts. It can get even worse: I can define an object (in C++ as well as
>> in python) that is not even equal to itself. Not that I felt the need for
>> that so far....
> 
> hehe... now you've picked my curiosity... how?
> 
> ps.
> def __eq__(self, other): return False
> does not count !

Sure it does! The rich comparison methods can very well be used to define
whatever semantics you want. Now I agree that 

def __eq__(self, other):
    if self is other:
       return False
    ... # do something more sane


doesn't make much sense usually. Or maybe even never. Still, it illustrates
the point: object identity is not to be confused with two objects being
part of an equality relation.

Diez



More information about the Python-list mailing list