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

Nick Coghlan ncoghlan at gmail.com
Wed Apr 19 13:01:28 CEST 2006


Nick Coghlan 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.
> 
> Utterly magical to anyone not already familiar with the use of *args, though.

A different idea from another part of the thread would be to allow a parameter 
list rather than an identifier after **:

   def f(**(paramA, paramB=10)):
       print paramA, paramB

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-3000 mailing list