Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two different values for same variable "args"

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
like image 619
Richard Avatar asked Dec 08 '22 04:12

Richard


1 Answers

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.).

like image 99
Martijn Pieters Avatar answered Dec 11 '22 10:12

Martijn Pieters