How To See Complete Traceback?
I have added an assert(0) in a function to understand the sequence of function calls to this function. Ex: def my_func(): ...lines of code... assert(0) ...more lines of
Solution 1:
Use traceback
module for this. I.e.
>>> import traceback
>>> def my_func():
... my_other_func()
...
>>> def my_other_func():
... my_third()
...
>>> def my_third():
... print "Stack"
... traceback.print_stack()
... print "Extracted"
... print repr(traceback.extract_stack())
...
>>>
>>> my_func()
Stack
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in my_func
File "<stdin>", line 2, in my_other_func
File "<stdin>", line 3, in my_third
Extracted
[('<stdin>', 1, '<module>', None),
('<stdin>', 2, 'my_func', None),
('<stdin>', 2, 'my_other_func', None),
('<stdin>', 5, 'my_third', None)]
>>>
Post a Comment for "How To See Complete Traceback?"