How do I tell what happens when I call a function in python, as in, I have imported a module and want to call a function from it. I need to tell what functions this function calls and where they are located as it executes. Very similar to a traceback, but without an error. traceback.format_stack()
won't work because I can't place it in the source code to run. Any ideas how to use this?
Example:
import amodule
#do something here?
amodule.some_method()
#or maybe here?
output:
File <fname1> in line 13, in <module>
module.some_method()
File <fname2> in line 53, in <module>
module2.some_other_method()
and so on
How can I best accomplish this?
Edit: The use I am thinking of for this is where there is a module composed of several files, which reference each other. If I want to edit a particular function, I need to know where and what to edit. I would rather not search through the source code to find the whole long chain of what happens where