This fixes issue #1 #2
+65
-2
@@ -1,4 +1,4 @@
|
|||||||
from Simulation import Simulation
|
'''
|
||||||
class Vault:
|
class Vault:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._treasure = "gold"
|
self._treasure = "gold"
|
||||||
@@ -15,4 +15,67 @@ class Vault:
|
|||||||
if self.__dict__ != self._attributes:
|
if self.__dict__ != self._attributes:
|
||||||
print("attribute deleted!")
|
print("attribute deleted!")
|
||||||
return self._treasure
|
return self._treasure
|
||||||
|
|
||||||
|
v=Vault()
|
||||||
|
print(v.treasure)
|
||||||
|
'''
|
||||||
|
'''
|
||||||
|
class Vault:
|
||||||
|
def __init__(self):
|
||||||
|
self._treasure = "gold"
|
||||||
|
self._original_dict = dict(self.__dict__)
|
||||||
|
|
||||||
|
def __setattr__(self, name, value):
|
||||||
|
if name != "_treasure" and name in self.__dict__ and self._original_dict.get(name) != value:
|
||||||
|
print("attribute deleted!")
|
||||||
|
self.__dict__[name] = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def treasure(self):
|
||||||
|
if self.__dict__ != self._original_dict:
|
||||||
|
print("attribute deleted!")
|
||||||
|
return self._treasure
|
||||||
|
v = Vault()
|
||||||
|
print(v.treasure)
|
||||||
|
'''
|
||||||
|
'''
|
||||||
|
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
|
||||||
|
|
||||||
|
v = Vault()
|
||||||
|
print(v.treasure)
|
||||||
|
'''
|
||||||
|
|
||||||
|
class Vault:
|
||||||
|
def __init__(self):
|
||||||
|
self._treasure = "gold"
|
||||||
|
|
||||||
|
def __setattr__(self, name, value):
|
||||||
|
if name != "_attributes" and name not in self.__dict__:
|
||||||
|
print("attribute deleted!")
|
||||||
|
self.__dict__[name] = value
|
||||||
|
self._attributes = dict(self.__dict__)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def treasure(self):
|
||||||
|
if self.__dict__ != self._attributes:
|
||||||
|
print("attribute deleted!")
|
||||||
|
return self._treasure
|
||||||
|
|
||||||
|
v = Vault()
|
||||||
|
print(v.treasure)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user