[Python-ideas] get method for sets?

Mathias Panzenböck grosser.meister.morti at gmx.net
Wed May 16 22:16:25 CEST 2012


On 05/16/2012 08:19 PM, Chris Rebert wrote:
> On Wed, May 16, 2012 at 9:20 AM, Steven D'Aprano<steve at pearwood.info>  wrote:
>> Mike Meyer wrote:
>>
>>> But my question was actually whether or not there was a reason for it
>>> not existing. Has there been a previous discussion of this?
>>
>> Aye yai yai, have there ever.
>>
>> http://mail.python.org/pipermail/python-bugs-list/2005-August/030069.html
>>
>> If you have an hour or two spare, read this thread:
>>
>> http://mail.python.org/pipermail/python-dev/2009-October/093227.html
>>
>> By the way, I suggest that a better name than "get" is pick(), which once
>> was (but no longer is) suggested by Wikipedia as a fundamental set
>> operation.
>>
>> http://en.wikipedia.org/w/index.php?title=Set_%28abstract_data_type%29&oldid=461872038#Static_sets
>>
>>
>> It seems to me that it has been removed because:
>>
>> - the actual semantics of what it means to get/pick a value from
>>   a set are unclear; and
>> - few, if any, set implementations actually provide this method.
>
> Objective-C's NSSet calls it "anyObject" and doesn't specify much
> about it (in particular, its behavior when called repeatedly), mainly
> just that "the selection is not guaranteed to be random". I haven't
> poked around to see how it actually behaves in practice.
>
> C#'s ISet has First() and Last(), but merely as extension methods.
>
> Java, Ruby, and Haskell don't seem to include any such operation in
> their generic set interfaces.
>

Ruby's Set has first() but not last(). That saied I'm -1 on a get/pick method for a set.

> Cheers,
> Chris
> --
> http://rebertia.com
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas




More information about the Python-ideas mailing list