Reputation: 4883
I have a big python script, with multiple files, and I need to know where a method was called. Is there a backtrace function in python like debug_backtrace in php?
Upvotes: 5
Views: 4780
Reputation: 215039
See the traceback module.
import traceback
def foo():
bar()
def bar():
baz()
def baz():
traceback.print_stack()
# or trace = traceback.extract_stack()
foo()
Upvotes: 9
Reputation: 1303
If you would like to debug python
import pdb
then drop a
pdb.set_trace()
Where ever you would like to start debugging
see this site for more information
http://docs.python.org/library/pdb.html
Upvotes: 3