Terry Reedy wrote: > "Talin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> Now, suppose you wanted to have 'key' be a keyword-only argument. > > Why? Why not let the user type the additional argument(s) without the > parameter name?
Because for some functions (e.g. min()/max()) you want to use *args, but support some additional keyword arguments to tweak a few aspects of the operation (like providing a "key=x" option). Currently, to support such options, you need to accept **kwds, then go poking around inside the dict manually. This PEP simply allows you to request that the interpreter do such poking around for you, rather than having to do it yourself at the start of the function. I used to be a fan of the idea, but I'm now tending towards a -0, as I'm starting to think that wanting keyword-only arguments for a signature is a sign that the first argument to the function should have been an iterable, rather than accepting *args. However, there are syntactic payoffs that currently favour using *args instead of accepting an iterable as the first argument to a function. I recently went into a lot more detail on that topic as part of the py3k discussion of set literals [1]. I'd like to turn that message into the core of a PEP eventually, but given the target would be Python 2.6 at the earliest, there are plenty of other things higher on my to-do list. Cheers, Nick. [1] http://mail.python.org/pipermail/python-3000/2006-April/001504.html -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com