Set & Frozenset?

Tim Golden mail at timgolden.me.uk
Sun Mar 8 19:33:09 CET 2009


Tim Golden wrote:
> Diez B. Roggisch wrote:
>> Hans Larsen schrieb:
>>> Could you help me ?
>>>             How could I "take" an elemment from a set or a frozenset 
>>> .-) ?
>>>
>>>                     From a string (unicode? Python<3), or from a 
>>> tuple,or from a list: Element by index or slice.
>>>                     From a dict: by key.
>>>                     But what concerning a set or frozenset!
>>>
>>>          hope somebody can help!
>>
>> You iterate over them. If you only want one value, use
>>
>>
>> iter(the_set).next()
> 
> or the_set.pop ()

Which will, in addition, remove it from the set.
(May not be what you want :) ).

TJG



More information about the Python-list mailing list