How can I make ipdb show more lines of context while debugging?

前端 未结 6 1928
慢半拍i
慢半拍i 2021-02-01 13:08

By default, during debugging in IPython, ipdb shows one line above and one line below the current position in code.

Is there an easy way to make the area shown a bit b

6条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-01 13:37

    If you want to stop execution in a running system, as others said, use:

    ipdb.set_trace(context=number_of_lines)
    

    For running some function or an object's method modifying this context lines is a little bit tricky. The only way I found was:

    ipdb.__main__._init_pdb(context=number_of_lines).runcall(callable, *args, **kwargs)
    

    In case it serves someone.

提交回复
热议问题