My code is, for better or worse, rife with single letter variables (it's physics stuff, so those letters are meaningful), as well as NumPy's, which I'm often interacting with.
我的代码是,无论好坏,充斥着单个字母的变量(它是物理的东西,所以那些字母是有意义的),以及NumPy的,我经常与之交互。
When using the Python debugger, occasionally I'll want to look at the value of, say, n
. However, when I hit n<enter>
, that's the PDB command for (n)ext
, which has a higher priority. print n
works around looking at it, but how can I set it?
当使用Python调试器时,我偶尔会想看看,比如说,n.但是,当我点击n
4 个解决方案
#1
71
Use an exclamation mark !
before a statement to have it run :
使用惊叹号!在语句之前运行:
python -m pdb test.py
> /home/user/test.py(1)<module>()
-> print('foo')
(Pdb) !n = 77
(Pdb) !n
77
(Pdb) n
foo
> /home/user/test.py(2)<module>()
-> print('bar')
(Pdb)
#2
11
You can use semicolons, so just put something else in front of it:
你可以用分号,所以在它前面放点别的东西:
ipdb> print n
2
ipdb> n
> 145 <some code here>
146
147
ipdb> 1; n=4
1
ipdb> print n
4
#3
2
That is not the direct answer to your question, but it may help you: PuDB is a console-based visual interface for PDB which separates commands from variable manipulation by design.
这并不是您问题的直接答案,但它可能会对您有所帮助:PuDB是一个基于conso的PDB可视化界面,它通过设计将命令和变量操作分离开来。
#4
-1
Eric IDE, Wing IDE & Spyder to mention just a few all have visual debuggers that are worth a go as they separate the display of values from the commands.
Eric IDE, Wing IDE & Spyder提到的只是少数几个都有可视调试器,当它们将值的显示从命令中分离出来时,这些调试器是值得一试的。
#1
71
Use an exclamation mark !
before a statement to have it run :
使用惊叹号!在语句之前运行:
python -m pdb test.py
> /home/user/test.py(1)<module>()
-> print('foo')
(Pdb) !n = 77
(Pdb) !n
77
(Pdb) n
foo
> /home/user/test.py(2)<module>()
-> print('bar')
(Pdb)
#2
11
You can use semicolons, so just put something else in front of it:
你可以用分号,所以在它前面放点别的东西:
ipdb> print n
2
ipdb> n
> 145 <some code here>
146
147
ipdb> 1; n=4
1
ipdb> print n
4
#3
2
That is not the direct answer to your question, but it may help you: PuDB is a console-based visual interface for PDB which separates commands from variable manipulation by design.
这并不是您问题的直接答案,但它可能会对您有所帮助:PuDB是一个基于conso的PDB可视化界面,它通过设计将命令和变量操作分离开来。
#4
-1
Eric IDE, Wing IDE & Spyder to mention just a few all have visual debuggers that are worth a go as they separate the display of values from the commands.
Eric IDE, Wing IDE & Spyder提到的只是少数几个都有可视调试器,当它们将值的显示从命令中分离出来时,这些调试器是值得一试的。