What value should be passed to make a function use the default argument value?
apardon at forel.vub.ac.be
Wed Oct 4 10:07:08 CEST 2006
On 2006-10-03, LaundroMat <Laundro at gmail.com> wrote:
> 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..
> Thanks in advance.
One possible way to do what I think you want is to code as follows:
class Default (object):
if var is Default:
var = 1
return var * 2
More information about the Python-list