Lambda in Python…
May 9, 2007 § 2 Comments
Is like watching trailer of a movie. Exciting, but not quite the real thing.
Why get so excited about it? It’s just an anonymous function. A nameless function that could be created on run-time. Doing just about everything you wish.
No, It doesn’t do just about everything, GVR would have been so mad if it does. Below are limitations of lambda in Python:
- Only takes 1 expression.
- Cannot takes statements.
But that doesn’t stop lambda from being cool. It can:
- perform pretty funky math expression inside your defined functions.
- perform built-in python functions, e.g. all sorts of string manipulation. Imagine pulling out large “string” data that doesn’t look quite right on your web form.
No, I’m not bashing Lambda. Nor that I wish for it to be more powerful. There’s exact need for lambda in Python. It cannot be abused by people too lazy to press “return” or “def” but it can modify things quickly anywhere.
I am glad that lambda doesn’t try to be the “real” functional languages such as Scheme because that would seriously bastardized readability.