equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

Alan Isaac aisaac at american.edu
Thu Jun 28 15:52:13 CEST 2007

A.T.Hofkamp wrote:

>>>>a = Car2(123)
>>>>b = Car2(123)
>>>>a == b
> True
> set([Car2(123), Car2(123)])
> I get a set with two equal cars, something that never happens with a set
> my math teacher once told me.

Then your math teacher misspoke.
You have two different cars in the set,
just as expected.  Use `is`.

This is good behavior.

Alan Isaac

More information about the Python-list mailing list