[Python-Dev] Retrieve an arbitrary element from a setwithoutremoving it (original) (raw)
Raymond Hettinger python at rcn.com
Thu Nov 5 02:07:23 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 ]
[Steven D'Aprano]
Anyway, given the level of opposition to the suggestion, I'm no longer willing to carry the flag for it. If anyone else -- perhaps the OP -- feels they want to take it any further, be my guest.
[geremy condra]
I've said before that I'd like there to be one, standard way of doing this. A function call- set.pick() seems reasonably named to me- is probably the cleanest way to do that. Absent that, an example in the docs that illustrates the preferred idiom would be great.
Summarizing my opposition to a new set method:
- there already are at least two succinct ways to get the same effect
- those ways work with any container, not just sets
- set implementations in other languages show that this isn't needed.
- there is value to keeping the API compact
- isn't needed for optimization (selecting the same value in a loop makes no sense)
- absence of real-world code examples that would be meaningfully improved
I would be happy to add an example to the docs so that this thread can finally end.
Raymond
- 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 ]