pre-PEP generic objects
Steven Bethard
steven.bethard at gmail.com
Tue Nov 30 11:39:42 EST 2004
Peter Otten wrote:
> Steven Bethard wrote:
>
>>def __eq__(self, other):
>> """x.__eq__(y) <==> x == y"""
>> return (isinstance(other, self.__class__)
>> and self.__dict__ == other.__dict__)
>
> This results in an asymmetry:
>
[snip]
>
> Whether this is intended, I don't know. If someone can enlighten me...
>
> In any case I would prefer self.__class__ == other.__class__ over
> isinstance().
Unintended. I'll switch to
self.__class__ == other.__class__
or
type(self) == type(other)
Any preference?
Steve
More information about the Python-list
mailing list