Identifing current function
Mahrt, Dallas
dallasm at aiinet.com
Thu Jan 22 12:28:24 EST 2004
> -----Original Message-----
> From: Brian Donovan [mailto:john at doe.com]
> Sent: Wednesday, January 21, 2004 6:22 PM
> To: python-list at python.org
> Subject: Identifing current function
>
>
> Hi all,
>
> Is there a way to identify the current function. For example:
>
> class A:
> def B(self):
> print current_function_name
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
import traceback
def getFuncName():
# get the stack frame of the caller of this func
stack = traceback.extract_stack()[-2]
# get the function/method name
return stack[2]
-
Dallas S. Mahrt
More information about the Python-list
mailing list