when I tried to run this code , I got an error
class Pizza:
def __init__(self, name):
self.name= name
@property
def name(self):
return self.name
@name.setter
def name(self,name):
print(self.name)
pizza = Pizza(["cheese", "tomato"])
the error :
RuntimeError: maximum recursion depth exceeded
But when I changed the code by making (name) private ,it works fine !
class Pizza:
def __init__(self, name):
self._name= name
@property
def name(self):
return self._name
@name.setter
def name(self,name):
print(self.name)
pizza = Pizza(["cheese", "tomato"])
why I got an error at first , and why it fixed when I make (name) private ?