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

前端 未结 6 1885
慢半拍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:35

    You can type l in ipdb to show a few more lines of the current context

    and you can keep hitting l and it continue revealing more lines from the file

    If you want to show more lines of context around the current line you can type l to get the current line. And then type l curr_line - 10, curr_line + 10. Say I was on line 50 and I wanted to see the surrounding 20 lines. I would type: l 40,60 to see more.

    As noted by @jrieke in a comment, you can also hit ll to get a bigger chunk of context. One nice thing about ll is it will print all the way back from the start of the current method (whereas consecutive ls reveal further lines below your breakpoint).

提交回复
热议问题