Skip to content

Instantly share code, notes, and snippets.

@FFY00
Created August 16, 2021 23:34
Show Gist options
  • Save FFY00/8b2e9dbadf7bd7b668257385e7a92cda to your computer and use it in GitHub Desktop.
Save FFY00/8b2e9dbadf7bd7b668257385e7a92cda to your computer and use it in GitHub Desktop.
class cached_property(object): # type: ignore
def __init__(self, func):
self._func = func
def __get__(self, instance, owner):
attr = self._func(instance)
setattr(instance, self._func.__name__, attr)
return attr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment