pythonfunctiondebugging

Tracking Python code execution by printing accessed functions


I have an extensive Python project with many files. With the aim of debugging, I want to be able to run my program and have the names of the executed functions printed to the terminal. Is there a special way to call the Python file which does this?

I know of the solution concerning creating a printing function and decorating my functions to print their name on execution but since I have a large code manually decorating every function is lot. Is there some way to call the Python file in a way that it prints every accessed function?


Solution

  • Use sys.settrace to set a trace function on 'call' events.