[Python-Dev] Retrieve an arbitrary element from a setwithoutremoving it
python at rcn.com
Thu Nov 5 02:07:23 CET 2009
>> 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.
> 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:
1) there already are at least two succinct ways to get the same effect
2) those ways work with any container, not just sets
3) set implementations in other languages show that this isn't needed.
4) there is value to keeping the API compact
5) isn't needed for optimization (selecting the same value in a loop makes no sense)
6) 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.
More information about the Python-Dev