Dictionary : items()

Paul Rubin http
Thu Jan 22 03:53:11 EST 2009


Steven D'Aprano <steven at REMOVE.THIS.cybersource.com.au> writes:
> That is better written as:
> l = sorted(abcd.items(), key=lambda x:(x[1].lower(), x[0]))

In Python 2.x, I prefer the style

  l = sorted(abcd.iteritems(), key=lambda (k,v): (v.lower(), k))

but Python 3.0 breaks the tuple unpacking per some PEP.



More information about the Python-list mailing list