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

Class DictionaryRecord

example_code/item_061.py:187–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

item_061.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected