Checking default arguments
Igor V. Rafienko
igorr at ifi.uio.no
Fri Feb 2 13:30:53 EST 2007
Hi,
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
{}.pop seems to be able to make this dictinction.
I've checked the inspect module, but nothing obvious jumped at me. Any
hints?
Thanks,
ivr
--
"...but it's HDTV -- it's got a better resolution than the real world."
-- Fry, "When aliens attack"
More information about the Python-list
mailing list