ZeroDivisionError Traceback (most recent call last)
<ipython-input-2-b2e110f6fc8f> in <module>()
----> 1 func2(1)
<ipython-input-1-d849e34d61fb> in func2(x)
5 a = x
6 b = x - 1
----> 7 return func1(a, b)
<ipython-input-1-d849e34d61fb> in func1(a, b)
1 def func1(a, b):
----> 2 return a / b
3
4 def func2(x):
5 a = x
ZeroDivisionError: division by zero
Calling func2
results in an error, and reading the printed trace lets us see exactly what happened.
By default, this trace includes several lines showing the context of each step that led to the error.
Using the %xmode
magic function (short for Exception mode), we can change what information is printed.
%xmode
takes a single argument, the mode, and there are three possibilities: Plain
, Context
, and Verbose
.
The default is Context
, and gives output like that just shown before.
Plain
is more compact and gives less information: