1 # -*- coding: utf-8 -*-
3 __author__
= 'Daniel Greenfeld'
4 __email__
= 'pydanny@gmail.com'
9 class cached_property(object):
10 """ A property that is only computed once per instance and then replaces
11 itself with an ordinary attribute. Deleting the attribute resets the
14 def __init__(self
, func
):
15 self
.__doc
__ = getattr(func
, '__doc__')
18 def __get__(self
, obj
, cls
):
21 value
= obj
.__dict
__[self
.func
.__name
__] = self
.func(obj
)