Peter Otten: >>>> s = set(["one-and-only"]) >>>> item, = s >>>> item >'one-and-only' > >This works for any iterable and guarantees that it contains exactly one >item.
Nice!
>The comma may easily be missed, though.
You could write:
(item,) = s
But I'm not sure if this introduces additional overhead.
--
René Pijlman
Wat wil jij worden? http://www.carrieretijger.nl
--
http://mail.python.org/mailman/listinfo/python-list
