1class HauntedMansion:
2 def __init__(self, **kwargs):
3 for key, value in kwargs.items():
4 self.__setattr__(key, value)
5
6 def __getattr__(self, name):
7 return "Booooo, only ghosts here!"
8
9 def __setattr__(self, name, value):
10 object.__setattr__(self, f"spooky_{name}", value)
11
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
f | 1 | f | 1 | ||
2 | class HauntedMansion: | 2 | class HauntedMansion: | ||
3 | def __init__(self, **kwargs): | 3 | def __init__(self, **kwargs): | ||
4 | for key, value in kwargs.items(): | 4 | for key, value in kwargs.items(): | ||
n | 5 | self.__setattr__(key,value) | n | 5 | self.__setattr__(key, value) |
6 | 6 | ||||
t | 7 | def __getattr__(self, name_): | t | 7 | def __getattr__(self, name): |
8 | return "Booooo, only ghosts here!" | 8 | return "Booooo, only ghosts here!" | ||
9 | 9 | ||||
10 | def __setattr__(self, name, value): | 10 | def __setattr__(self, name, value): | ||
11 | object.__setattr__(self, f"spooky_{name}", value) | 11 | object.__setattr__(self, f"spooky_{name}", value) | ||
12 | 12 | ||||
13 | 13 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|