instance comparison
Fredrik Lundh
fredrik at pythonware.com
Thu Jul 24 14:05:31 EDT 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
False
>>> a is b
False
>>> str(a) == str(b)
True
</F>
More information about the Python-list
mailing list