How do I know where is a function was executed in Python? -
let's imagine, i've got module foo.py
declared function foofunc
:
def foofunc(): # smart things return
and 2 different modules — bar.py
, spam.py
, exists code directly executes function foo
module.
# `bar` module. rights reserved. foo import foofunc def run_foofunc(): return foofunc()
the same thing in module:
# `spam` module. rights reserved. foo import foofunc def run_foofunc(): return foofunc()
i need know executed function without knowledge of possible places. like:
def foofunc(): print inspect.executedfrom()
will in standard output
<pack.bar.run_foofunc>
does similar in real world?
running risk of not answering actual question, wrote need research , debugging.
i think traceback
module great that.
import traceback traceback.print_stack()
also take @ pdb
, allows interactively step through code during runtime.
Comments
Post a Comment