get the name of lambda

Piet van Oostrum piet at cs.uu.nl
Sat Oct 16 22:32:00 CEST 2004


>>>>> George Yoshida <ml at dynkin.com> (GY) wrote:

GY> Just out of curiosity, is there any way to get the name of a
GY> lambda expression? Lambdas are anonymous functions, so it's a
GY> stupid idea to get the name of it. But if it's possible, how
GY> could I?

You already said it: it's a stupid idea. Anonymous means: having no name,
so what is the name of an anonymous thing supposed to be.

GY> Let's take a simple example:
GY>   foo = lambda:None

In your example foo is not the name of the lambda. It is just a variable
whose value is the lambda expression.

-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl



More information about the Python-list mailing list