dom_beau dom_beau -4 years ago 63
Python Question

Access to class members within ipdb

Maybe this question will look simple but I'm trying to look at some member variables from within ipdb and I cannot see how.

Example:

class MyClass( object ):
def __init__( self, p ):
self.__p = p
pass # <--- breakpoint here!


I am sure that p is correct. In the debugger I enter:

ipdb> (self.__p)


and I get the following error message:

* * *AttributeError: 'MyClass' object has no attribute '__p'

It seems that self is the class, not the instance for the debugger.

Any idea about how to perform what I do?

I use Python 2.7.3 on IPython 0.12.1 on Kubuntu 12.04 - 64 bits.

Answer Source

See here for the reason, this is Pythons way of having "private" variables.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download