8th day of python challenges 111-117
This commit is contained in:
13
venv/lib/python3.6/site-packages/lazy_object_proxy/utils.py
Normal file
13
venv/lib/python3.6/site-packages/lazy_object_proxy/utils.py
Normal file
@@ -0,0 +1,13 @@
|
||||
def identity(obj):
|
||||
return obj
|
||||
|
||||
|
||||
class cached_property(object):
|
||||
def __init__(self, func):
|
||||
self.func = func
|
||||
|
||||
def __get__(self, obj, cls):
|
||||
if obj is None:
|
||||
return self
|
||||
value = obj.__dict__[self.func.__name__] = self.func(obj)
|
||||
return value
|
||||
Reference in New Issue
Block a user