get the name of lambda

George Yoshida ml at dynkin.com
Sat Oct 16 08:48:04 EDT 2004


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

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

foo.__name__(or foo.func_name) returns '<lambda>'.
I'm looking for a way to return 'foo', instead of '<lambda>'.

Thanks in advance.

-- George



More information about the Python-list mailing list