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:

>>> from bunch import Bunch
>>> class B(Bunch): pass
...
>>> B().__eq__(Bunch())
False
>>> Bunch().__eq__(B())
True

With indirect use of __eq__() this puzzling behaviour disappears:

>>> B() == Bunch()
False
>>> Bunch() == B()
False

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().

Peter
 

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to