forked from SVIG/python-bootcamp
update
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
from Simulation import Simulation
|
||||
class Vault:
|
||||
def __init__(self):
|
||||
self._treasure = "gold"
|
||||
self._attributes = dict(self.__dict__)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if name != "_attributes" and name not in self._attributes:
|
||||
print("attribute deleted!")
|
||||
self._attributes[name] = value
|
||||
super().__setattr__("_attributes", dict(self.__dict__))
|
||||
|
||||
@property
|
||||
def treasure(self):
|
||||
if self.__dict__ != self._attributes:
|
||||
print("attribute deleted!")
|
||||
return self._treasure
|
||||
|
||||
Reference in New Issue
Block a user