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

Lawrence Oluyede rhymes at myself.com
Tue Oct 3 22:30:21 CEST 2006

LaundroMat <Laundro at gmail.com> wrote:
> 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..

I don't know if I understand correctly here but:

def f(v=1):
    return v * 2

f() returns 2
f(1) returns 2 too

v = 1
f(v) returns 2 too

What do you mean?

Lawrence - http://www.oluyede.org/blog
"Nothing is more dangerous than an idea
if it's the only one you have" - E. A. Chartier

More information about the Python-list mailing list