Parameter sublists [was: An ordering question]

Peter Pearson ppearson at nowhere.invalid
Fri Mar 13 20:30:02 EDT 2009


On Fri, 13 Mar 2009 18:56:30 +0100, Hrvoje Niksic <hniksic at xemacs.org> wrote:
[snip]
> a.sort(key=lambda (x, y): b[y - 1], reverse=True)

Huh?  I had no idea one could do this:

>>> def g( ( ( x, y ), z ) ):
...   return y
... 
>>> g( ((1,2),3) )
2

What should I have read to learn that trick?

-- 
To email me, substitute nowhere->spamcop, invalid->net.



More information about the Python-list mailing list