[Python-Dev] Retrieve an arbitrary element from a setwithoutremoving it (original) (raw)
Raymond Hettinger python at rcn.com
Tue Oct 27 20:49:01 CET 2009
- Previous message: [Python-Dev] Retrieve an arbitrary element from a set withoutremoving it
- Next message: [Python-Dev] Retrieve an arbitrary element from a setwithoutremoving it
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[geremy condra]
Was it ever decided whether this would fall under the moratorium?
Decided isn't the right word: http://mail.python.org/pipermail/python-dev/2009-October/093373.html
FWIW, I'm a strong -1 on both proposals.
Just add a short get_one() function and a get_equivalent() recipe to your utils directory. That will get the job done (thought I don't expect that you will ever make much use of either one). No need to complexify a type that is currently very simple.
Raymond
P.S. get_equivalent: http://code.activestate.com/recipes/499299/ get_one = lambda s, default=None: next(iter(s), default)
The first works with all type that defines contains. The second works for any iterable. Neither of these concepts are specific to set objects.
- Previous message: [Python-Dev] Retrieve an arbitrary element from a set withoutremoving it
- Next message: [Python-Dev] Retrieve an arbitrary element from a setwithoutremoving it
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]