Added more test files from lectures.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
class Vault:
|
||||
def __init__(self):
|
||||
self._treasure = 'gold'
|
||||
self._original_attrs = self.__dict__.copy()
|
||||
|
||||
@property
|
||||
def treasure(self):
|
||||
if self.__dict__ != self._original_attrs:
|
||||
print('Attribute deleted!')
|
||||
return self._treasure
|
||||
def stuff(self):
|
||||
...
|
||||
|
||||
def __setattr__(self, key, value):
|
||||
self.__dict__[key] = value
|
||||
if key != '_original_attrs' and hasattr(self, '_original_attrs') and self.__dict__ != self._original_attrs:
|
||||
print('Attribute deleted!')
|
||||
|
||||
def __call__(self, *args):
|
||||
print(f"attempt to call {args}")
|
||||
|
||||
v = Vault()
|
||||
v(1,2,3)
|
||||
Reference in New Issue
Block a user