What is the right way to debug in iPython notebook?

前端 未结 10 1707
不知归路
不知归路 2020-11-30 16:50

As I know, %debug magic can do debug within one cell.

However, I have function calls across multiple cells.

For example,

In[1]:          


        
10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-30 17:27

    You can always add this in any cell:

    import pdb; pdb.set_trace()
    

    and the debugger will stop on that line. For example:

    In[1]: def fun1(a):
               def fun2(a):
                   import pdb; pdb.set_trace() # debugging starts here
               return fun2(a)
    
    In[2]: fun1(1)
    

提交回复
热议问题