Function reference -> name?

Emile van Sebille emile at
Fri Nov 14 15:38:08 CET 2003

"Rene Pijlman" < at> wrote in
message news:2lo9rvsob1ejjju20ut308temf0p8l0gbo at
> When I have a reference to a function (as in parameter 'function' of
> below), how can I get the name of that function ('f2' in the example
> below)?
> def f1(function):
>     pass
>     # How to get 'f2' from function?
> def f2():
>     pass
> f1(f2)

>>> def f1():pass
>>> f1.func_name
>>>>>> dir (f1)
['__call__', '__class__', '__delattr__', '__dict__', '__doc__',
'__get__', '__ge
tattribute__', '__hash__', '__init__', '__module__', '__name__',
'__new__', '__r
educe__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
 'func_code', 'func_defaults', 'func_dict', 'func_doc',
'func_globals', 'func_na



Emile van Sebille
emile at

More information about the Python-list mailing list