(self)
| 1 | def cached_property(f): |
| 2 | """returns a cached property that is calculated by function f""" |
| 3 | def get(self): |
| 4 | try: |
| 5 | return self._property_cache[f] |
| 6 | except AttributeError: |
| 7 | self._property_cache = {} |
| 8 | x = self._property_cache[f] = f(self) |
| 9 | return x |
| 10 | except KeyError: |
| 11 | x = self._property_cache[f] = f(self) |
| 12 | return x |
| 13 | |
| 14 | return property(get) |
no test coverage detected