I have a Product class defined in Python as below:
class Product:
@property
def price(self):
return self.price
@price.setter
def price(self, value):
if value < 10:
raise ValueError("price can't be negative")
self.price = value
When I try to set the price attribute of a new instance of Product (prod):
prod = Product()
prod.price = 25
print(prod.price)
I get an error saying:
RecursionError: maximum recursion depth exceeded
Can someone please explain what I'm doing wrong here...
return self.priceself.price = value