[Python-ideas] get method for sets?
Ben Finney
ben+python at benfinney.id.au
Wed May 16 17:43:06 CEST 2012
Mike Meyer <mwm at mired.org> writes:
> On Wed, 16 May 2012 17:39:10 +1000
> Ben Finney <ben+python at benfinney.id.au> wrote:
> > If by “get” you mean to get an *arbitrary* item, not a specific item,
> > then what's the problem? You already have ‘set.pop’, as you point out.
>
> And, as I also pointed out, it's not useful in the case where you need
> to preserve the set for future use.
Then, if ‘item = next(iter(foo_set))’ doesn't suit you, perhaps you'd
like ‘item = set(foo_set).pop()’.
Regardless, I think you have your answer: Like most things that can
already be done by composing the existing pieces, this corner case
hasn't met the deliberately-high bar for making a special method just to
do it.
I still haven't seen you describe the use case where the existing ways
of doing this aren't good enough.
--
\ “Men never do evil so completely and cheerfully as when they do |
`\ it from religious conviction.” —Blaise Pascal (1623–1662), |
_o__) Pensées, #894. |
Ben Finney
More information about the Python-ideas
mailing list