[Python-3000] Cleaning up argument list parsing (was Re: More wishful thinking)
Guido van Rossum
guido at python.org
Wed Apr 19 15:50:07 CEST 2006
On 4/19/06, Nick Coghlan <ncoghlan at gmail.com> wrote:
> Guido van Rossum wrote:
> > Here's a related but more complicated wish: define a function in such
> > a way that certain parameters *must* be passed as keywords, *without*
> > using *args or **kwds. This may require a new syntactic crutch.
>
> A single '*' could indicate that no additional positional arguments were
> permitted.
>
> def f(*, paramA, paramB=10):
> print paramA, paramB
>
> Here paramA and paramB can only be passed as keywords, and paramA *has* to be
> passed as it has no default.
I once considered and rejected this syntax since another logical
interpretation would be that any positional arguments are accepted but
*ignored*.
> Utterly magical to anyone not already familiar with the use of *args, though.
But so would any other newly invented syntax, probably, so that
doesn't count heavily.
Would *None be too bizarre?
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list