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 09:52:13 EDT 2007
A.T.Hofkamp wrote:
>>>>a = Car2(123)
>>>>b = Car2(123)
>>>>a == b
>
> True
>
>>>>set([a,b])
>
> 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`.
http://docs.python.org/ref/comparisons.html
This is good behavior.
Cheers,
Alan Isaac
More information about the Python-list
mailing list