bionic787
12/11/2013 - 2:17 AM

How to get the name of a source file and the current function name in runtime?

How to get the name of a source file and the current function name in runtime?

# get the filename
sys._getframe().f_code.co_filename  

# get the function name
sys._getframe().f_code.co_name