You can the parent of a function with inspect:
This combined with Nilamo's code could be the start of a useful way to create program flow graphically.
This combined with Nilamo's code could be the start of a useful way to create program flow graphically.
import inspect def function1(): print('Function1 called from: {}'.format(inspect.stack()[1][3])) def function3(): print('Function1 called from: {}'.format(inspect.stack()[1][3])) function1() def function2(): print('Function2 called from: {}'.format(inspect.stack()[1][3])) function3() def main(): function2() if __name__ == '__main__': main()results:
Output:Function2 called from: main
Function1 called from: function2
Function1 called from: function3
Process finished with exit code 0