Use asottile.cached_property.

This commit is contained in:
Anthony Sottile
2014-06-01 16:41:58 -07:00
parent 619bca2bdc
commit 39c4ee6e96
7 changed files with 5 additions and 45 deletions

View File

@@ -6,23 +6,6 @@ import shutil
import sys
class cached_property(object):
"""Like @property, but caches the value."""
def __init__(self, func):
self.__name__ = func.__name__
self.__module__ = func.__module__
self.__doc__ = func.__doc__
self._func = func
def __get__(self, obj, cls):
if obj is None:
return self
value = self._func(obj)
obj.__dict__[self.__name__] = value
return value
def memoize_by_cwd(func):
"""Memoize a function call based on os.getcwd()."""
@functools.wraps(func)