Tim Chase wrote:

> When you have a set, known to be of length one, is there a "best"
> ("most pythonic") way to retrieve that one item?
 
>>> s = set(["one-and-only"])
>>> item, = s
>>> item
'one-and-only'

This works for any iterable and guarantees that it contains exactly one
item. The comma may easily be missed, though.

Peter
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to