Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

print values in pdb

When I trace to a function, inside the function I would like to print the values of those variable names with underscore in the beginning, eg. p __seqLen. It keeps showing AttributeError: AttributeError("Converter instance has no attribute '__seqLen'",) I also tried to use p self.__seqLen. This is also not working. How can I print those values?

like image 537
Ken Avatar asked May 11 '11 05:05

Ken


2 Answers

p locals()
p globals()

could help.

like image 50
lprsd Avatar answered Oct 13 '22 01:10

lprsd


You might be running into Python's private name mangling. Python will mangle identifiers that begin with two or more underscores and do not end with two or more underscores. It transforms __somename into _Class__somename.

like image 7
zeekay Avatar answered Oct 13 '22 01:10

zeekay