Two questions on lambda:

Duncan Booth duncan.booth at invalid.invalid
Fri Jun 24 09:25:57 EDT 2005


Xavier Décoret wrote:

> Is there a particular syntax for lambda that I am missing 
> or is it simply limited and I cannot do what I want with lambda.

Lambda is deliberately limited. Just define a function.

The only downside to defining a function is that you have to think of a 
name for it, but that name is simply a variable like any other and can be 
rebound at will.

Any attempt to write an expression such as:

   f = lambda x : y=x*x,y+y

should instantly set off lots of alarm bells in your mind. Defining a 
lambda simply to assign it to a name is obviously wrong: it should be a 
function definition instead.



More information about the Python-list mailing list