Best way to extract an item from a set of len 1
reply.in.the.newsgroup at my.address.is.invalid
Wed Jan 25 16:21:42 CET 2006
>>>> s = set(["one-and-only"])
>>>> item, = s
>This works for any iterable and guarantees that it contains exactly one
>The comma may easily be missed, though.
You could write:
(item,) = s
But I'm not sure if this introduces additional overhead.
Wat wil jij worden? http://www.carrieretijger.nl
More information about the Python-list