8

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?

1
  • I have the same problem via the IPython repl. Commented Feb 26, 2019 at 20:43

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.