1PREFIX = "spooky_"
2INVALID_MESSAGE = "Booooo, only ghosts here!"
3
4class HauntedMansion:
5
6 def __init__(self, **kwargs):
7 for key, value in kwargs.items():
8 setattr(self, key, value)
9
10 def __setattr__(self, name, value):
11 object.__setattr__(self, PREFIX + name, value)
12
13 def __getattribute__(self, name):
14 try:
15 to_return = object.__getattribute__(self, name)
16 except:
17 return INVALID_MESSAGE
18 return to_return
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
02.11.2024 21:21
02.11.2024 21:22