assymetry between a == b and a.__eq__(b) (WAS: pre-PEP genericobjects)
tjreedy at udel.edu
Wed Dec 1 22:07:09 CET 2004
"Steven Bethard" <steven.bethard at gmail.com> wrote in message
>>>def __eq__(self, other):
>>> """x.__eq__(y) <==> x == y"""
>>> return (isinstance(other, self.__class__)
Since an instance of a subclass is an instance of a parent class, but not
vice versa, I believe you introduce here the assymetry you verify below.
>>> and self.__dict__ == other.__dict__)
>> This results in an asymmetry:
>>>>>from bunch import Bunch
>>>>>class B(Bunch): pass
Terry J. Reedy
More information about the Python-list