What value should be passed to make a function use the default argument value?
Rob De Almeida
ralmeida at gmail.com
Wed Oct 4 00:03:52 CEST 2006
> Suppose I have this function:
> def f(var=1):
> return var*2
> What value do I have to pass to f() if I want it to evaluate var to 1?
> I know that f() will return 2, but what if I absolutely want to pass a
> value to f()? "None" doesn't seem to work..
If you *absolutely* want to pass a value and you don't know the default
value (otherwise you could just pass it):
>>> import inspect
>>> v = inspect.getargspec(f) # first default value
More information about the Python-list