def runs_once(func):
 @wraps(func)
 def decorated(*args, **kwargs):
  if (not hasattr(decorated, 'return_value')):
   decorated.return_value = func(*args, **kwargs)
  return decorated.return_value
 decorated = _wrap_as_new(func, decorated)
 return serial(decorated)

def runs_once ( func ) : @ wraps ( func ) def decorated ( * args , ** kwargs ) : if ( not hasattr ( decorated , 'return_value' ) ) : decorated . return_value = func ( * args , ** kwargs ) return decorated . return_value decorated = _wrap_as_new ( func , decorated ) return serial ( decorated )
decorator preventing wrapped function from running more than once .