相同变量“args"的两个不同值 [英] Two different values for same variable "args"
问题描述
我正在从 python 脚本调用一个方法,其中一个变量作为 args.一旦我进入该方法,当我试图查看变量 args 的值时,打印 args"并执行 'args' 会显示两个不同的值.谁能告诉我这两个命令有什么区别.
我希望这两个命令显示相同的值.
(Pdb) 打印参数<lib.framework.testmanager.RunArgs 对象在 0xb26acac>(Pdb) 参数args = u = spec = {'excludeHosts': None, 'evacuateAllData': True, 'WaitTime': None, 'IssueType': 'Host Disconnect', 'performObjectUpgrade': True, 'downgradeFormat': False}结果 = 真
args
是 PDB 调试器命令.使用 !args
显示实际变量.
请参阅调试器命令部分::><块引用>
a(rgs)
打印当前函数的参数列表.
和
<块引用>[!]声明
在当前堆栈帧的上下文中执行(一行)语句.感叹号可以省略,除非语句的第一个单词类似于调试器命令.
(强调我的).
在您的 args
输出中,您可以在第一行看到 args
参数值.
就我个人而言,我觉得 (a)rgs
命令有点无意义;它使用 str()
而不是 repr()
打印所有值;这使得具有相似 __str__
输出值的对象之间的差异不可见(例如 str
与 unicode
,或 BeautifulSoup 元素与带有HTML 等).
I am invoking a method from python script which has one of the variable as args. Once I step into the method, when I am trying to see the value of the the variable args, "print args" and just executing 'args' display two different values. Can anyone please let me know whats the difference between these two commands.
I expected both the commands to display same value.
(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
is a PDB debugger command. Use !args
to show the actual variable.
See the Debugger Commands section:
a(rgs)
Print the argument list of the current function.
and
[!]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.
(Emphasis mine).
In your args
output you can see the args
argument value on the first line.
Personally, I find the (a)rgs
command a little pointless; it prints all values using str()
instead of repr()
; this makes the difference between objects with similar __str__
output values invisible (such as str
vs. unicode
, or a BeautifulSoup Element vs. a string with HTML, etc.).
这篇关于相同变量“args"的两个不同值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!