I use PyCharm Community Edition 3.4.
I have added self.__a
to Watches.
This is my example:
class Box:
def __init__(self, a, b, c):
self.__a = a
self._b = b
self.c = c
d = 0 #Breakpoint.
a = Box(1, 2, 3)
So, I start debugging and stop at the breakpoint. The self.__a
watch shows {AttributeError}'Box' object has no attribute 'a'.
I press Alt + F8 and evaluate self.__a = a
. The result is None
.
Then I evaluate self.__a
and the result is 1
.
My watch for self.__a
still shows {AttributeError}'Box' object has no attribute 'a'
. I delete it. Then I add another watch self.__a
. It shows 1
.
Could you clarify what is going on here?
it is because box has no __a
it gets name mangled ...
see also: Name_mangling#Python
it becomes
Box._Box__a
and if you change it to watch
self._Box__a
it will show you the proper value
but it should also show up in the variables list view (in the center of the debug run panel)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With