En Fri, 02 Feb 2007 15:30:53 -0300, Igor V. Rafienko <[EMAIL PROTECTED]> escribió:
>> I was wondering whether it was possible to find out which parameter > value is being used: the default argument or the user-supplied one. > That is: > > def foo(x, y="bar"): > # how to figure out whether the value of y is > # the default argument, or user-supplied? > > foo(1, "bar") => user-supplied > foo(1) => default You can use None as a flag: def foo(x, y=None): if y is None: y="bar" ... If None is valid, use your own flag: _marker=object() def foo(x, y=_marker): if y is _marker: y="bar" ... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list