Death to tuples!
Mike Meyer
mwm at mired.org
Thu Dec 1 11:48:24 EST 2005
Antoon Pardon <apardon at forel.vub.ac.be> writes:
> I know what happens, I would like to know, why they made this choice.
> One could argue that the expression for the default argument belongs
> to the code for the function and thus should be executed at call time.
> Not at definion time. Just as other expressions in the function are
> not evaluated at definition time.
The idiom to get a default argument evaluated at call time with the
current behavior is:
def f(arg = None):
if arg is None:
arg = BuildArg()
What's the idiom to get a default argument evaluated at definition
time if it were as you suggested?
<mike
--
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list
mailing list