[Python-Dev] Retrieve an arbitrary element from a set withoutremoving it

geremy condra debatem1 at gmail.com
Wed Nov 4 22:32:39 CET 2009


On Wed, Nov 4, 2009 at 6:34 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Wed, 4 Nov 2009 11:54:47 am Greg Ewing wrote:
>> Steven D'Aprano wrote:
>> > I don't know how expensive it is to create a set iterator,
>>
>> Not expensive enough to justify burdening the set type with
>> extra functionality that will be extremely rarely used.
>
> As my previous posts on this topic tried to convey, this isn't primarily
> about efficiency, but about discoverability and obviousness.
>
> 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.
>
>
>
> --
> Steven D'Aprano

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. Is there any kind of consensus on either point?

Geremy Condra


More information about the Python-Dev mailing list