On Tue, Nov 3, 2009 at 12:19 AM, Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
Cameron Simpson wrote:

Personally, I'm for the iteration spec in a lot of ways.

Firstly, a .get()/.pick() that always returns the same element feels
horrible. Is there anyone here who _likes_ it?

State might cause people to use this to iterate which would be just plain wrong. The 2 things I have a bad feeling about is:
1. random.choice could be a pythonic alternative to what some have mentioned here but it doesn't work on sets. The following code raises TypeError: 'set' object does not support indexing:
    import random
this is kinda ironic: http://en.wikipedia.org/wiki/Axiom_of_choice
2. If I store objects in a set and modify their attributes I have no O(1) way of getting the objects back if I stumble upon an equivalent object. In cases like that I'd have to either iterate over the set or use a dict with key == value. I have a feeling the "get" or "peek" api could cater to this need. A use case for this could be an implementation of a cookie jar with a set of cookies where equivalence is defined by the name and domain.