instance comparison

Fredrik Lundh fredrik at pythonware.com
Thu Jul 24 05:24:17 EDT 2008


King wrote:

> Is this mean when you have overridden __str__ method then it comapre
> with results of __str__ or else it will comapre whether they are the
> same instances?

Comparisons uses __cmp__ or the rich comparison set; see

     http://docs.python.org/ref/customization.html

for details.

Sets and dictionaries, also relies on hashing (the __hash__ method, also 
described on the linked page).

The __str__ method only affects printing and conversion to string.

</F>




More information about the Python-list mailing list