[Python-3000] Cleaning up argument list parsing (was Re: More wishful thinking)

Guido van Rossum guido at python.org
Tue Apr 18 00:44:49 CEST 2006


On 4/17/06, Walter Dörwald <walter at livinglogic.de> wrote:
> BTW, do we want to allow foo(1, *args1, 2, *args2, 3)?
>
> And what about foo(bar=17, **kwargs1, baz=23, **kwargs2)?

There's probably not much use for those but at least the first isn't
ambiguous so could be allowed if it doesn't complicate the
implementation. The second begs the questions about what works if
kwargs1 and kwargs2 contain overlapping keys with different values;
it's probably best not to allow this and perhaps **kwds should only be
allowed as the very last parameter. Since keyword args aren't
position-dependent, there's no reason to need a different position.

If we did end up allowing multiple **kwds, the code implementing calls
should check that they don't overlap with each other or with other
keyword args or with named positional args, to be consistent with the
current state of affairs, where f(a=1, **{'a':2}) is rejected with a
TypeError. (The complexity of all those cross-checks is hopefully
enough to dissuade anyone from proposing this. :-)

--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list