Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

'args' variable name is used in my project. When I use pdb.set_trace to debug, I want to print what's in the 'args' variable. The result is far different from my expect and I figured out pdb uses 'args' as its reserved word to keep something else. My question is how to print this 'args' variable without having to change the variable name to something not conflicting. Thanks.

I am using Python 3.4, in Windows command line console. Python pseudo code sample:

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() 
like image 581
Rob L Avatar asked Jan 16 '15 00:01

Rob L


1 Answers

OK. I figured it out. Using pdb command, p(args) or pp(args) should save it.

like image 143
Rob L Avatar answered Sep 29 '22 19:09

Rob L