What value should be passed to make a function use the default argument value?

Tim Chase python.list at tim.thechases.com
Tue Oct 3 22:43:12 CEST 2006


> 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..

 >>> def f(var=1):
...     return var*2
...
 >>> f()
2
 >>> f(0.5)
1.0
 >>> f(123)
246
 >>> f('hello')
'hellohello'


I'm not sure I follow your problem...what's stopping you from 
passing a value?

-tkc







More information about the Python-list mailing list