lambda in list comprehension acting funny

John Ladasky john_ladasky at sbcglobal.net
Wed Jul 11 16:21:34 EDT 2012


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.

I know the historical reason that Python ended up with lambda, it was requested by people in the Lisp community.  While I appreciate some of the Lisp-like features which did find their way into Python (especially being able to treat code as data, and functions as objects), I've found that lambda does nothing for me.



More information about the Python-list mailing list