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

Nick Coghlan ncoghlan at gmail.com
Mon Nov 2 13:27:48 CET 2009


Antoine Pitrou wrote:
> Cameron Simpson <cs <at> zip.com.au> writes:
>> 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?
> 
> I do. Since the caller is asking for an arbitrary element, returning the same
> element is legitimate. It's funny how people seem to have a problem with the
> word "arbitrary" :)

Agreed. Arbitrary is arbitrary - for a stateless method that returns an
arbitrary result, return the same value every time is fine.

> And I'm -1 on any implicit iteration attaching some state to the object. If you
> want to iterate, there's already an obvious way to it.

Also agreed.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------


More information about the Python-Dev mailing list