Not this one the other one, from a dictionary

Jean Daniel jeandaniel.browne at gmail.com
Tue Sep 22 13:04:02 EDT 2009


Building on the answers of the others, a simple one liner, no side
effect, not the fastest I guess:

>>> d={'a': 'bob', 'b': 'stu'}
>>> set( d.keys() ).difference( [ 'a' ] ).pop()
'b'

Note the square brackets for the parameter of difference(). 'The
string 'a' and the list [ 'a' ] are both iterable but really are
different.



More information about the Python-list mailing list