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

Class MissingPropertyRecord

example_code/item_061.py:110–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108print("Example 5")
109try:
110 class MissingPropertyRecord:
111 def __getattr__(self, name):
112 if name == "bad_name":
113 raise AttributeError(f"{name} is missing")
114 value = f"Value for {name}"
115 setattr(self, name, value)
116 return value
117
118 data = MissingPropertyRecord()
119 assert data.foo == "Value for foo" # Test this works

Callers 1

item_061.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected