| 185 | |
| 186 | print("Example 12") |
| 187 | class DictionaryRecord: |
| 188 | def __init__(self, data): |
| 189 | self._data = data |
| 190 | |
| 191 | def __getattribute__(self, name): |
| 192 | # Prevent weird interactions with isinstance() used |
| 193 | # by example code harness. |
| 194 | if name == "__class__": |
| 195 | return DictionaryRecord |
| 196 | print(f"* Called __getattribute__({name!r})") |
| 197 | data_dict = super().__getattribute__("_data") |
| 198 | return data_dict[name] |
| 199 | |
| 200 | data = DictionaryRecord({"foo": 3}) |
| 201 | print("foo: ", data.foo) |