Not this one the other one, from a dictionary

Sion Arrowsmith sion at viridian.paintbox
Tue Sep 22 14:01:37 CEST 2009

Vlastimil Brom  <vlastimil.brom at> wrote:
>>>> other_key = (set(data_dict.iterkeys()) - set([not_wanted_key,])).pop()

other_key = set(data_dict.iterkeys()).difference([not_wanted]).pop()
saves you the construction of an unnecessary set instance. At the
cost of a bit more verbosity, you can get rid of a second set:

key_set = set(data_dict.iterkeys())
other_key = key_set.pop()

although the loss of clarity compared to the one liner can't be
worth the miniscule benefit in this case.


   under construction

More information about the Python-list mailing list