def with_defaults ( method , nparams , defaults = None ) : args = [ None ] * nparams if not defaults else defaults + max ( nparams - len ( defaults ) , 0 ) * [ None ] return method ( * args )
python method definition with default values to params
Call method with nparams positional parameters all non - specified defaults are passed None .
def with_defaults(method, nparams, defaults=None):
  """Call method with nparams positional parameters, all non-specified defaults are passed None.

  :method: the method to call
  :nparams: the number of parameters the function expects
  :defaults: the default values to pass in for the last len(defaults) params
  """
  args = [None] * nparams if not defaults else defaults + max(nparams - len(defaults), 0) * [None]
  return method(*args)