Consider the following pseudocode:
func1():
  func2() #func2 is called inside func1
My question is, in func2 can I access the name of the function it was called from? In this case, func1? Thanks!
Consider the following pseudocode:
func1():
  func2() #func2 is called inside func1
My question is, in func2 can I access the name of the function it was called from? In this case, func1? Thanks!
 
    
    import inspect
def func2():
    cframe = inspect.currentframe()
    func = inspect.getframeinfo(cframe.f_back).function
    print 'called from ' + func
def func1():
    func2()
func2()
func1()
Output:
called from <module>
called from func1
