1SPOOKY_PREFIX = 'spooky_'
2
3class HauntedMansion:
4 """Make everything spooky."""
5
6 def __init__(self, **kwargs):
7 for key, value in kwargs.items():
8 self.__setattr__(key,value)
9
10 def __setattr__(self, key, value):
11 spooky_key = SPOOKY_PREFIX + key
12 object.__setattr__(self, spooky_key, value)
13
14 def __getattr__(self, item):
15 return 'Booooo, only ghosts here!'
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
02.11.2024 21:29