def cached_property(fun):
 @wraps(fun)
 def get(self):
  try:
   return self._cache[fun]
  except AttributeError:
   self._cache = {}
  except KeyError:
   pass
  ret = self._cache[fun] = fun(self)
  return ret
 return property(get)

def cached_property ( fun ) : @ wraps ( fun ) def get ( self ) : try : return self . _cache [ fun ] except AttributeError : self . _cache = { } except KeyError : pass ret = self . _cache [ fun ] = fun ( self ) return ret return property ( get )
a property that .