Parameter sublists [was: An ordering question]
On Fri, 13 Mar 2009 18:56:30 +0100, Hrvoje Niksic 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: Parameter sublists [was: An ordering question]
On Fri, Mar 13, 2009 at 5:30 PM, Peter Pearson wrote: > On Fri, 13 Mar 2009 18:56:30 +0100, Hrvoje Niksic 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? Don't bother. It's been excised in Python 3.0. Cheers, Chris -- I have a blog: http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Parameter sublists [was: An ordering question]
On Mar 14, 5:39 am, Chris Rebert wrote: > On Fri, Mar 13, 2009 at 5:30 PM, Peter Pearson > wrote: > > On Fri, 13 Mar 2009 18:56:30 +0100, Hrvoje Niksic > > 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? > > Don't bother. It's been excised in Python 3.0. > > Cheers, > Chris > > -- > I have a blog:http://blog.rebertia.com Thank you very much. These many solutions ? I think programming is not my forte :-) :-) -- http://mail.python.org/mailman/listinfo/python-list