PyCharm and debugging personal attributes

I am using PyCharm Community Edition 3.4.

I added self.__ain the watch.

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'm starting to debug and stop at the breakpoint. Watch self.__ashow{AttributeError}'Box' object has no attribute 'a'.

I click Alt+ F8and rate self.__a = a. The result is None.

Then I evaluate self.__a, and the result is 1.

My watch for self.__ashow {AttributeError}'Box' object has no attribute 'a'. I delete it. Then I add another watch self.__a. He is showing 1.

Could you explain what is happening here?

+4
source share
1 answer

this is because there is no field __a

he gets the name mangled ...

. : Name_mangling#Python

Box._Box__a

,

self._Box__a 

( )

+3

Source: https://habr.com/ru/post/1568072/


All Articles