同一变量的两个不同值 "args"

Two different values for same variable "args"

我正在从 python 脚本中调用一个方法,该脚本将其中一个变量作为参数。 一旦我进入该方法,当我试图查看变量 args 的值时,"print args" 并只是执行 'args' 显示两个不同的值。 谁能告诉我这两个命令有什么区别。

我希望这两个命令显示相同的值。

(Pdb) print args
<lib.framework.testmanager.RunArgs object at 0xb26acac>

(Pdb) args
args = <lib.framework.testmanager.RunArgs object at 0xb26acac>
u = <upgradelib.UpgradeManager object at 0x946cf8c>
spec = {'excludeHosts': None, 'evacuateAllData': True, 'WaitTime': None, 'IssueType': 'Host Disconnect', 'performObjectUpgrade': True, 'downgradeFormat': False}
result = True

args 是 PDB 调试器命令。使用!args显示实际变量。

参见 Debugger Commands section:

a(rgs)
Print the argument list of the current function.

[!]statement
Execute the (one-line) statement in the context of the current stack frame. The exclamation point can be omitted unless the first word of the statement resembles a debugger command.

(强调我的)。

在您的 args 输出中,您可以在第一行看到 args 参数值。

就我个人而言,我觉得 (a)rgs 命令有点毫无意义;它使用 str() 而不是 repr() 打印所有值;这使得具有相似 __str__ 输出值的对象之间的差异不可见(例如 strunicode,或 BeautifulSoup 元素与具有 HTML 的字符串等)。