1class HauntedMansion:
2 """Access the attributes of a class only with a specific prefix."""
3 def __init__(self, **kwargs):
4 for key, value in kwargs.items():
5 self.__setattr__(key, value)
6
7 def __setattr__(self, key, value):
8 object.__setattr__(self, f"spooky_{key}", value)
9
10 def __getattr__(self, key):
11 return "Booooo, only ghosts here!"
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK