Determine function name from within that function (without using traceback)

The Solution to Determine function name from within that function (without using traceback) is


import inspect

def foo():
   print(inspect.stack()[0][3])
   print(inspect.stack()[1][3]) #will give the caller of foos name, if something called foo

~ Answered on 2011-02-21 15:16:04


Most Viewed Questions: