I am using Jupyter Notebook.
Considering the following code:
cell1
import pdbtest
cell2
%debug -b pdbtest.py:3
pdbtest.test(4,6)
end of cell2
pdbtest.py
is a module located in the same folder as the notebook, containing:
def test(a,b):
print("hello")
a=a*2
print("goodbye")
b=b*2
Normally the %debug
magic should set a breakpoint on the third line of the module. When run , this code returns:
Breakpoint 1 at /home/depot/notebooks/pdbtest.py:3
NOTE: Enter 'c' at the ipdb> prompt to continue execution.
hello
goodbye
It seems the console has well understood the file and the location where the breakpoint should be, and give the return of the function. However it doesn't stop on the breakpoint!
Anyone has experienced the same?
In your example, the %debug
magic command is only valid for the Python code that follows it in the same line, i.e., nothing.
If you want it to be valid for the whole cell, then you should use %%debug
:
%%debug -b pdbtest.py:3
pdbtest.test(4,6)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With