প্রোপার্টিস
class Pizza:
def __init__(self, toppings):
self.toppings = toppings
@property
def pineapple_allowed(self):
return False
pizza = Pizza(["cheese", "tomato"])
print(pizza.pineapple_allowed)
pizza.pineapple_allowed = TrueFalse
Traceback (most recent call last):
File "/Users/nuhil/Documents/Python/property.py", line 11, in <module>
pizza.pineapple_allowed = True
AttributeError: can't set attribute
Last updated