Step-by-step debugging with IPython

后端 未结 15 2091
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 03:43

From what I have read, there are two ways to debug code in Python:

  • With a traditional debugger such as pdb or ipdb. This supports c

相关标签:
15条回答
  • 2020-12-02 04:11

    the right, easy, cool, exact answer for the question is to use %run macro with -d flag.

    In [4]: run -d myscript.py
    NOTE: Enter 'c' at the ipdb>  prompt to continue execution.        
    > /cygdrive/c/Users/mycodefolder/myscript.py(4)<module>()
          2                                                            
          3                        
    ----> 4 a=1                                            
          5 b=2
    
    0 讨论(0)
  • 2020-12-02 04:13

    If you type exit() in embed() console the code continue and go to the next embed() line.

    0 讨论(0)
  • 2020-12-02 04:17

    Did you try this tip?

    Or better still, use ipython, and call:

    from IPython.Debugger import Tracer; debug_here = Tracer()
    

    then you can just use

    debug_here()
    

    whenever you want to set a breakpoint

    0 讨论(0)
提交回复
热议问题