Let's say I have a class A
class A:
__slots__ = ['_x']
def __init__(self):
self._x = 10
@property
def x(self):
return self._x
And I want to restrcit assigning to a._x
from anywhere except other instance's methods.
How do I do that? Is that even possible in Python?
The thing is to write a class which attributes is changeable only within particular methods and never directly from outside.