Fate of lambda, Functional Programming in Python...

Dan Schmidt dfan at harmonixmusic.com
Sat Aug 21 12:02:46 EDT 2004


Jeff Sandys <sandysj at juno.com> writes:

| How about this use of lambda?
| (from another post 'RE: How to sort this kind of list easily?' today)
| 
| |  Or if you want to sort only on your Id, use a lambda:
| |  l.sort(lambda x,y: cmp(x[0],y[0]))

In 2.4, you actually don't need a lambda:

   l.sort( key = operator.itemgetter( 0 ) )

but I too would be very sad to see anonymous functions go away,
although I find the current syntax pretty ugly.

Dan

-- 
http://www.dfan.org



More information about the Python-list mailing list