parameters: (func)
return_statement: return _cached_func
docstring: Decorator cached makes the function to cache its result and return it in duplicate calls.
docstring_summary: Decorator cached makes the function to cache its result and return it in duplicate calls.
docstring_tokens: Decorator cached makes the function to cache its result and return it in duplicate calls .
function: def cached(func):
      """Decorator cached makes the function to cache its result and return it in duplicate calls."""
      prop_name = '__cached_' + func.__name__
  
      @functools.wraps(func)
      def _cached_func(self):
          try:
              return getattr(self, prop_name)
          except AttributeError:
              val = func(self)
              setattr(self, prop_name, val)
              return val
  
      return _cached_func
function_tokens: def cached ( func ) : prop_name = '__cached_' + func . __name__ @ functools . wraps ( func ) def _cached_func ( self ) : try : return getattr ( self , prop_name ) except AttributeError : val = func ( self ) setattr ( self , prop_name , val ) return val return _cached_func