Hidden attributes



examples/oop/attributes/hidden.py
class Thing:
    def __init__(self):
        self.__hidden = 'lake'

    def get_hidden(self):
        return self.__hidden

examples/oop/attributes/class_with_hidden_attribute.py
from hidden import Thing

t = Thing()
#print(t.__hidden)  # AttributeError: 'Thing' object has no attribute '__hidden'

print(t.get_hidden())    # lake

print(dir(t))            # ['_Thing__hidden',  ...]

print(t._Thing__hidden)  # lake

t._Thing__hidden = 'Not any more'
print(t._Thing__hidden)  # Not any more