instance comparison

Fredrik Lundh fredrik at
Thu Jul 24 20:05:31 CEST 2008

King skrev:

> The the class is not subclass of another one. Problem still persist.
> The code is pretty huge and I am trying to post the information as
> clear as possible.

feel free to *add* stuff to the following example until it breaks, if 
that's easier:

 >>> class Spam:
...     def __init__(self, label):
...             self.label = label
...     def __str__(self):
...             return self.label
 >>> a = Spam("an object")
 >>> a
<__main__.Spam instance at 0xb7e8faac>
 >>> print a
an object
 >>> b = Spam("an object")
 >>> b
<__main__.Spam instance at 0xb7e8fb6c>
 >>> print b
an object
 >>> a == b
 >>> a is b
 >>> str(a) == str(b)


More information about the Python-list mailing list