[Python-ideas] get method for sets?
Mike Meyer
mwm at mired.org
Wed May 16 22:00:33 CEST 2012
More information about the Python-ideas mailing list
Wed May 16 22:00:33 CEST 2012
- Previous message: [Python-ideas] get method for sets?
- Next message: [Python-ideas] Composability and concurrent.futures
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, 17 May 2012 01:43:06 +1000 Ben Finney <ben+python at benfinney.id.au> wrote: > 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()’. This is precisely what bugs me about this case. There's not one obvious way to do it. There's a collection of ways that are all in some ways/cases problematical. They all involve creating a scratch object from the set and using it's API to (possibly destructively) get the one value that's wanted. In a way, it reminds me of the discussions that eventually led to the if else expression being added. > 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. And it's already been discussed to death. *That's* what I was trying to find out. If it hadn't been, I'd have put together a serious proposal. > I still haven't seen you describe the use case where the existing ways > of doing this aren't good enough. That, of course, is a subjective judgment. <mike -- Mike Meyer <mwm at mired.org> http://www.mired.org/ Independent Software developer/SCM consultant, email for more information. O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
- Previous message: [Python-ideas] get method for sets?
- Next message: [Python-ideas] Composability and concurrent.futures
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list