On 2006-10-03, LaundroMat <[EMAIL PROTECTED]> 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. >
I think the only general solution for your problem would be to define a defaulter function. Something like the following: Default = object() def defaulter(f, *args): while args: if args[-1] is Default: args = args[:-1] else: break return f(*args) The call: defaulter(f, arg1, arg2, Default, ..., Default) would then be equivallent to: f(arg1, arg2) Or in your case you would call: defaulter(f, Default) -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list