class people():
def __init__(self,name):
self.__name=name
@property
def name(self):
return self.__name
@name.setter
def name(self,name):
if not isinstance(name,str):
raise TypeError('expected a string')
self.__name=name
me=people("john")
print(me.name)
me.name="tony"
print(me.name)
output:
john
tony