I was testing the idea of using @property
in OOP:
class Person(object):
@property
def name(self):
return self.name
@name.setter
def name(self, newname):
self.name = newname
james = Person()
james.name = 'James Bond'
print(james.name)
>>> RecursionError: maximum recursion depth exceeded
Somehow this gives me an Error for recursion??
but if I change self.name
to self._name
, it seems to solve the problem. So I guess I can not set a self.name
while I am using name()
as a @property
?