简体   繁体   English

相同变量“args”的两个不同值

[英]Two different values for same variable “args”

I am invoking a method from python script which has one of the variable as args. 我从python脚本调用一个方法,其中一个变量为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. 一旦我进入方法,当我试图看到变量args的值时,“print args”并且只是执行'args'会显示两个不同的值。 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. args是PDB调试器命令。 Use !args to show the actual variable. 使用!args显示实际变量。

See the Debugger Commands section : 请参见“ 调试器命令”部分

a(rgs) 一个(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. args输出中,您可以在第一行看到args参数值。

Personally, I find the (a)rgs command a little pointless; 就个人而言,我发现(a)rgs命令有点无意义; it prints all values using str() instead of repr() ; 它使用str()而不是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.). 这使得具有相似__str__输出值的对象之间的区别不可见(例如strunicode ,或BeautifulSoup元素与带有HTML的字符串等)。

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

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