1class HauntedMansion():
2 """Represent a haunted mansion."""
3
4 _PREFIX = ("spooky_",)
5
6 def __init__(self, **kwargs):
7 for key, value in kwargs.items():
8 setattr(self, key, value)
9
10 def __getattr__(self, name):
11 return "Booooo, only ghosts here!"
12
13 def __setattr__(self, name, value):
14 object.__setattr__(self, HauntedMansion._PREFIX[0] + name, value)
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
02.11.2024 21:23