2

I'm used to debugging in Python with PyCharm.

Now I'm trying to learn using ipdb with Jupyter(Lab to be precise).

But the two following behaviors are really puzzling me !

First one

breakpoint()
for i in range(3):
    print(i)

Then in the debugger :

--Return--
None
> <ipython-input-10-45409e3598c5>(1)<module>()
----> 1 breakpoint()
      2 for i in range(3):
      3     print(i)

ipdb>  n

    [... skipped 1 hidden frame]

    [... skipped 1 hidden frame]

    [... skipped 1 hidden frame]

    [... skipped 1 hidden frame]

> c:\users\icar\anaconda3\envs\jlab3\lib\site-packages\ipython\core\interactiveshell.py(3349)run_ast_nodes()
   3347                     to_run.append((node, 'single'))
   3348 
-> 3349                 for node,mode in to_run:
   3350                     if mode == 'exec':
   3351                         mod = Module([node], [])

Why ipdb next makes ipdb stopping in run_ast_nodes ?

Isn't it supposed to be an equivalent to step over ?

Second one

for i in range(3):
    breakpoint()
    print(i)

Then in the debugger :

None
> <ipython-input-9-2b8431878fa0>(3)<module>()
      1 for i in range(3):
      2     breakpoint()
----> 3     print(i)

ipdb>  c

0
None
> <ipython-input-9-2b8431878fa0>(2)<module>()
      1 for i in range(3):
----> 2     breakpoint()
      3     print(i)

ipdb>  c

1
None
> <ipython-input-9-2b8431878fa0>(3)<module>()
      1 for i in range(3):
      2     breakpoint()
----> 3     print(i)

What can explain ipdb continue alternates stopping on line 3, then 2, then 3 again ?

I guess I'm missing something, but I can't get it, it's just elementary stuff...

Icarwiz
  • 184
  • 6

0 Answers0