lambda in list comprehension acting funny
John O'Hagan
research at johnohagan.com
Thu Jul 12 01:29:42 EDT 2012
More information about the Python-list mailing list
Thu Jul 12 01:29:42 EDT 2012
- Previous message (by thread): lambda in list comprehension acting funny
- Next message (by thread): lambda in list comprehension acting funny
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 11 Jul 2012 13:21:34 -0700 (PDT) John Ladasky <john_ladasky at sbcglobal.net> wrote: > Exactly. It's threads like these which remind me why I never use lambda. I > would rather give a function an explicit name and adhere to the familiar > Python syntax, despite the two extra lines of code. I don't even like the > name "lambda". It doesn't tell you what it is (unless you're John McCarthy), > a function that you won't re-use and so you don't really need to give it a > persistent name. > > I haven't seen any lambdas in any Python library code, or in any of the > third-party modules I use (numpy, matplotlib, Biopython). Do they exist? > Because I have not been forced to do so, I haven't retained a space in the > top drawer of my programming brain for lambda. [...] +1 about the name, -1 about the usefulness. For example it's a clear and concise way to pass a key argument to min, max, sort and friends: sort(seq, key=lambda x: x.a) The alternative is to have trivial function definitions floating around the namespace which readers of the code have to search for. -- John
- Previous message (by thread): lambda in list comprehension acting funny
- Next message (by thread): lambda in list comprehension acting funny
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list