Sets and Membership Tests
Klaas
mike.klaas at gmail.com
Tue Jul 11 23:01:49 EDT 2006
JKPeck wrote:
> I would like to be able use sets where the set members are objects of a
> class I wrote.
> I want the members to be distinguished by some of the object content,
> but I have not figured out how a set determines whether two (potential)
> elements are identical. I tried implementing __eq__ and __ne__ and
> __hash__ to make objects with identical content behave as identical for
> set membership, but so far no luck.
__eq__ and __hash__ are necessary and sufficient. Code?
-Mike
More information about the Python-list
mailing list