繁体   English   中英

Python如何在与pdb上下文中的args关键字冲突时打印args变量

[英]Python how to print args variable when it conflicts with args keyword in pdb context

'args'变量名在我的项目中使用。 当我使用pdb.set_trace进行调试时,我想打印'args'变量中的内容。 结果与我的期望大不相同,我发现pdb使用'args'作为保留字以保留其他内容。 我的问题是如何打印这个'args'变量,而不必将变量名称更改为不冲突的东西。 谢谢。

我在Windows命令行控制台中使用Python 3.4。 Python伪代码示例:

args = dict(blah='blah'...)
... some code deal with args
def foo():
  pdb.set_trace() # when traced here, I type 'args' to show what it is, but looks like it's going to print arguments of foo method, which is None.
foo() 

好。 我想到了。 使用pdb命令,p(args)或pp(args)应该保存它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM