0

What's traceback line in Python ??

9th Oct 2019, 1:12 PM
Yusof
Yusof - avatar
3 Answers
+ 5
Traceback is the stack trace of where execution was at the point an exception was thrown. The stack trace shows each function call within the active stack of nested function calls to pinpoint where a function was when the exception was thrown. Imagine a scenario where the following functions are called in this pseudo stack trace (traceback): a() calls b() on line 3 of a.py. b() calls c() on line 18 of b.py. c() calls d() on line 23 of c.py. d() calls d() on line 9 of d.py. d() calls d() on line 9 of d.py. d() calls d() on line 9 of d.py. error() on line 12 of d.py. This pseudo stack trace shows the nested sequence of function calls until the error occurs. This example shows a recursive function d() called itself 2 times before the error. Hopefully this helps with understanding the purpose of traceback.
9th Oct 2019, 3:11 PM
David Carroll
David Carroll - avatar