def with_defaults(**default_funcs):
 def decorator(f):
  @wraps(f)
  def method(self, *args, **kwargs):
   for (name, func) in iteritems(default_funcs):
    if (name not in kwargs):
     kwargs[name] = func(self)
   return f(self, *args, **kwargs)
  return method
 return decorator

def with_defaults ( ** default_funcs ) : def decorator ( f ) : @ wraps ( f ) def method ( self , * args , ** kwargs ) : for ( name , func ) in iteritems ( default_funcs ) : if ( name not in kwargs ) : kwargs [ name ] = func ( self ) return f ( self , * args , ** kwargs ) return method return decorator
decorator for providing dynamic default values for a method .