A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-April/088148.html below:

[Python-Dev] Getting values stored inside sets

[Python-Dev] Getting values stored inside sets [Python-Dev] Getting values stored inside sets"Martin v. Löwis" martin at v.loewis.de
Fri Apr 3 18:43:05 CEST 2009
> I've stumbled upon an oddity using sets.  It's trivial to test if a
> value is in the set, but it appears to be impossible to retrieve a
> stored value, other than by iterating over the whole set. 

Of course it is. That's why it is called a set: it's an unordered
collection of objects, keyed by nothing.

If you have a set of elements, and you check "'foo' in s", then
you should be able just to use the string 'foo' itself for whatever
you want to do with it - you have essentially created a set of
strings. If you think that 'foo' and Element('foo') are different
things, you should not implement __eq__ in a way that they are
considered equal.

Regards,
Martin
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4