Skip to content

Commit a68892e

Browse files
committed
init
0 parents  commit a68892e

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

dephell_versioning/__init__.py

Whitespace-only changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
3+
# https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
4+
# https://github.com/pydanny/cached-property/blob/master/cached_property.py
5+
class cached_property(object): # noqa: N801
6+
"""
7+
A property that is only computed once per instance and then replaces itself
8+
with an ordinary attribute. Deleting the attribute resets the property.
9+
"""
10+
def __init__(self, func):
11+
self.__doc__ = func.__doc__
12+
self.func = func
13+
14+
def __get__(self, obj, cls):
15+
if obj is None:
16+
return self
17+
value = obj.__dict__[self.func.__name__] = self.func(obj)
18+
return value

0 commit comments

Comments
 (0)