MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / __getattribute__

Method __getattribute__

example_code/item_061.py:191–198  ·  view source on GitHub ↗
(self, name)

Source from the content-addressed store, hash-verified

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
200data = DictionaryRecord({"foo": 3})
201print("foo: ", data.foo)

Callers

nothing calls this directly

Calls 1

__getattribute__Method · 0.45

Tested by

no test coverage detected