如何阻止 PDB 每次打印最后一个变量
How to stop PDB from printing the last variable everytime
鉴于以下互动环节:
$ python -c "import pdb; pdb.set_trace()"
--Return--
> <string>(1)<module>()->None
(Pdb) print "hello"
hello
(Pdb)
hello
(Pdb)
hello
(Pdb) pass
(Pdb)
(Pdb)
每个新语句都会打印出你好。为什么会发生这种情况,我该如何阻止它?
它不是 "printing the last variable",它是在您按回车键但未指定命令或 python 表达式时重复最后一个 pdb 命令。
为什么会这样?好吧,因为作者认为它可能是一个有用的快捷方式,因此您不必一遍又一遍地重新输入 'n' 或 's'。 It's actually documented FWIW:
Entering a blank line repeats the last command entered. Exception: if the last command was a list command, the next 11 lines are listed.
至于 "how to stop it" 部分,我想您必须 fork pdb 或创建您自己的调试器子类,但我不明白您为什么要这样做 - 它实际上是一个非常有用的功能一个调试器(对于 shell 来说确实很烦人,但这不是我们在这里谈论的,是吗?)。
鉴于以下互动环节:
$ python -c "import pdb; pdb.set_trace()"
--Return--
> <string>(1)<module>()->None
(Pdb) print "hello"
hello
(Pdb)
hello
(Pdb)
hello
(Pdb) pass
(Pdb)
(Pdb)
每个新语句都会打印出你好。为什么会发生这种情况,我该如何阻止它?
它不是 "printing the last variable",它是在您按回车键但未指定命令或 python 表达式时重复最后一个 pdb 命令。
为什么会这样?好吧,因为作者认为它可能是一个有用的快捷方式,因此您不必一遍又一遍地重新输入 'n' 或 's'。 It's actually documented FWIW:
Entering a blank line repeats the last command entered. Exception: if the last command was a list command, the next 11 lines are listed.
至于 "how to stop it" 部分,我想您必须 fork pdb 或创建您自己的调试器子类,但我不明白您为什么要这样做 - 它实际上是一个非常有用的功能一个调试器(对于 shell 来说确实很烦人,但这不是我们在这里谈论的,是吗?)。