|
7
|
You want to determine the name of the currently running function, e.g. to create error messages that don't need to be changed when copied to other functions. Function _getframe of module sys does this and much more.
Inspired by Recipe 10.4 in O'Reilly's Perl Cookbook. Python's sys._getframe(), new in 2.1, offers information equivalent to Perl's builtin caller(), __LINE__ and __FILE__. If you need this for older Python releases, see recipe http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52315, "Obtaining the name of a function/method". |
Add a comment
Sign in to comment
Download
Copy to clipboard
