class A:
name = 'default'
a = A()
a.name = 'new'
print('Name =', a.name)
class A:
__name__ = 'default'
getName = lambda self: self.__name__
def setName(self, name):
self.__name__ = name
a = A()
a.setName('new')
print('Name =', a.getName())
class A:
def __init__(self, name='default'):
self._name = name
@property
def name(self):
return self._name
@name.setter
def name(self, value):
self._name = value
a = A()
print(a.name)
a.name = 'test'