Two questions on lambda:

Christophe Delord no.spam
Fri Jun 24 12:45:27 EDT 2005


hello,

On Fri, 24 Jun 2005 14:48:16 +0200, Xavier Décoret wrote:

> Hi,
> 
> In the same spirit, how can I do to compute intermediary values in the
> 
> body of a lambda function. Let's say (dummy example):
> 
> f = lambda x : y=x*x,y+y
> 
> 
> In languages like Caml, you can do:
> 
> let f = function x -> let y=x*x in y+y;;
> 
> Does the lambda : syntax in python allow for the same kind of
> constructs?

You can define another lambda function with a default value for the y
parameter. For instance:

f = lambda x: (lambda y=x*x: y+y)()


> 
> Thanks.



More information about the Python-list mailing list