On Fri, 2008-09-12 at 00:10 +0200, Mathias Panzenböck wrote:
The only thing I'd like would be anonymous classes (like in java) and anonymous functions:
I don't think anything else concerning statement as expression is in any way necessary or handy.
At one time I also perceived a shortcoming in lambda. You could continue to see it this way, or you could see it (like I now do) that it's not lambda that's limited (it effectively allows an arbitrary number of expressions), but rather the fact that a statement cannot be be used as an expression.
For instance, the following is currently legal in Python:
lambda x, y: ( x + y, x**2, y**2 )
But this is not:
lambda x, y: ( if x > y: x else: y )
Whether or not it's illegal is due to lambda being limited or because statements are castrated expressions is all a matter of your point of view. Extending lambda to allow statements would certainly fix *lambda*, but making statements into expressions fixes Python (IMHO, of course).