[Python-ideas] keyword arguments everywhere (stdlib) - issue8706

Ethan Furman ethan at stoneleaf.us
Sat Mar 3 00:56:48 CET 2012

Nick Coghlan wrote:
> On Sat, Mar 3, 2012 at 5:28 AM, Guido van Rossum <guido at python.org> wrote:
>> I would actually like to see a syntactic feature to state that an
>> argument *cannot* be given as a keyword argument (just as we already
>> added syntax to state that it *must* be a keyword).
> I currently write such code as:
>      def f(*args):
>          arg1, arg2, arg3 = args
> This gives rubbish error messages when the caller makes a mistake, but it works.
> The obvious syntactic alternative is allowing tuple expansion
> specifically for *args:
>    def f(*(arg1, arg2, arg3)):
>       pass

The problem with that is we then have '*' doing double duty as both 
tuple unpacking and keyword-only in the function signature:

     def herd(*(size, location), *, breed)


More information about the Python-ideas mailing list