How can I programmatically find the name of a method from within that method?

Jay Loden python at jayloden.com
Wed Aug 8 01:09:29 EDT 2007


kj7ny wrote:
> Is there a way that I can programmatically find the name of a method I
> have created from within that method?  I would like to be able to log
> a message from within that method (def) and I would like to include
> the name of the method from which it was written without having to
> hard-code that value in every message string.  While we're at it, is
> there a way to programmatically get the name of the class and the
> module while I'm at it?

This is a frequently asked question around here :-)

You should search the list archives for past threads, e.g:
http://aspn.activestate.com/ASPN/Mail/Message/python-list/3542665

-Jay



More information about the Python-list mailing list