简体   繁体   English

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

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

'args' variable name is used in my project. 'args'变量名在我的项目中使用。 When I use pdb.set_trace to debug, I want to print what's in the 'args' variable. 当我使用pdb.set_trace进行调试时,我想打印'args'变量中的内容。 The result is far different from my expect and I figured out pdb uses 'args' as its reserved word to keep something else. 结果与我的期望大不相同,我发现pdb使用'args'作为保留字以保留其他内容。 My question is how to print this 'args' variable without having to change the variable name to something not conflicting. 我的问题是如何打印这个'args'变量,而不必将变量名称更改为不冲突的东西。 Thanks. 谢谢。

I am using Python 3.4, in Windows command line console. 我在Windows命令行控制台中使用Python 3.4。 Python pseudo code sample: 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() 

OK. 好。 I figured it out. 我想到了。 Using pdb command, p(args) or pp(args) should save it. 使用pdb命令,p(args)或pp(args)应该保存它。

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

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