Get the name of a function

Grant Edwards invalid at invalid.invalid
Fri Aug 5 18:05:45 EDT 2011

On 2011-08-05, gervaz <gervaz at> wrote:

> Hi all, is there a way to retrive the function name like with
> self.__class__.__name__?

Not really.  There may not be any such thing as "the function name". A
function may have zero names, it may have a dozen names.  It may have
names but only in namespaces that aren't accessible.

This question comes up at least once a month, so look back through the
group for threads about finding an object's name, finding a
parameter's name, etc.

Here's a nice article on introspection, but what it talks about as a
"function name" probably isn't what you're interested in:

Here's a stack-overflow question similar to yours:

Grant Edwards               grant.b.edwards        Yow! But they went to MARS
                                  at               around 1953!!

More information about the Python-list mailing list