
Being unsatisfied with the way lambda works, i wondered what would the python guys think of this: class X: ____my_static_method = staticmethod(def (x, y): { ________some statements ____}) I hope decorators will be better for this case, but it's only an example. The word 'lambda' could be used instead of 'def', i don't know what would be better. The motivation of this suggestion is to improve consistency of the language and correcting the one-expression-lambda we currently have. Look how consistent Lua is in this regard. Passing functions to functions is considered useful by many people (essential, sometimes), but 'lambda' cannot be used even when all we need is a function that has an 'if' or an assignment, for example. 'lambda' seems to be a hack. Since unnamed functions can to be used anywhere, i chose braces as delimiters, but indentation would work normally inside them. Also, the syntax is easy to recognize and is not ambiguous. If Python (3.0? 2.5?) had this feature, i would be very happy! I suspect that this subject has already been discussed, but it's easier to find lambda tricks than a good rationale of its limitations.

Forgive a lurker, but...
Being unsatisfied with the way lambda works, i wondered what would the python guys think of this:
class X: ____my_static_method = staticmethod(def (x, y): { ________some statements ____})
I can't think of any reason why you wouldn't want to do: class X: def myStaticMethod(x, y): some statements myStaticMethod = staticmethod(myStaticMethod) I know its just an example, but I just don't get the allure of anonymous functions. There's no extra typing in this example, its not any more clear, and in fact, it looks less clear to me. That doesn't jump out at me saying 'function definition!'. And in situations where it may be less typing, its still IMHO always less clear. --Stephen

On Thu, Jul 29, 2004, marcus wrote:
Being unsatisfied with the way lambda works, i wondered what would the python guys think of this: [...]
While this isn't precisely off-topic for python-dev, it's been hashed so many times that it's better to see if you can get some consensus on comp.lang.python before bringing it up here. In fact, I'd say that you should have a full-fledged PEP before bringing it back to python-dev. -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ "To me vi is Zen. To use vi is to practice zen. Every command is a koan. Profound to the user, unintelligible to the uninitiated. You discover truth everytime you use it." --reddy@lion.austin.ibm.com
participants (3)
-
Aahz
-
IxokaI
-
marcus