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

Method __getattribute__

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

Source from the content-addressed store, hash-verified

88 self.exists = 5
89
90 def __getattribute__(self, name):
91 print(f"* Called __getattribute__({name!r})")
92 try:
93 value = super().__getattribute__(name)
94 print(f"* Found {name!r}, returning {value!r}")
95 return value
96 except AttributeError:
97 value = f"Value for {name}"
98 print(f"* Setting {name!r} to {value!r}")
99 setattr(self, name, value)
100 return value
101
102data = ValidatingRecord()
103print("exists: ", data.exists)

Callers 1

__getattribute__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected