[Python-Dev] Should the default equality operator compare values instead of identities?

"Martin v. Löwis" martin at v.loewis.de
Mon Nov 7 23:34:26 CET 2005

BJörn Lindqvist wrote:
> How would the value equality operator deal with recursive objects?
> class Foo:
>     def __init__(self):
>         self.foo = self
> Seems to me that it would take atleast some special-casing to get
> Foo() == Foo() to evalute to True in this case...

This is sort-of supported today:

 >>> a=[]
 >>> a.append(a)
 >>> b=[]
 >>> b.append(b)
 >>> a == b


More information about the Python-Dev mailing list