[Python-Dev] PEP 457: Syntax For Positional-Only Parameters

Larry Hastings larry at hastings.org
Wed Oct 9 22:03:29 CEST 2013


On 10/09/2013 08:25 PM, Terry Reedy wrote:
> I am sure that he has rejected any backward-incompatible change, as 
> would I. Allowing keyword passing *is* compatible, so I would not 
> guess about that.

I don't know where to look for this discussion, and I read it quite some 
time ago.  So I this is only dimly remembered.  If it's crucial to the 
outcome of this discussion maybe we can ask Guido for a fresh ruling.

But.  As I recall the discussion, he was specifically against supporting 
keyword arguments for range, and he was adamant that range argument 
parsing was not to change in the slightest degree, 
backwards-incompatible or not.  Again, my almost-certainly-misremembered 
quote: "range isn't changing.  deal with it."


> An *optional* positional-only parameter can be and sometimes is or has 
> been denoted by [], as with dir([object]).  In Python 3, [] is no 
> longer used for normal optional params, which always have defaults. 
> The dict signature could be (and maybe once was) given as 
> dict([mapping-or-iterable], *kwds).
>
> There is a definite problem, though with required positional-only 
> params. If these are rarer than at present, then it may matter less to 
> people the indicator is. If they think it obnoxious, they will not 
> have to see it so often,

Most of the positional-only parameters in CPython are of the "required" 
variety.

Some examples?  Almost all of the "built-in functions":

    http://docs.python.org/3/library/functions.html

only accept positional-only parameters.  So, almost anywhere you see a 
required parameter on that page, it is a required positional-only parameter.

Also, many (most?) of the really old C extensions exclusively use 
PyArg_ParseTuple, so those too.  My go-to example is curses simply 
because that one gave me the most psychological scarring.  But there are 
loads of them.  Anything that parses arguments solely with 
PyArg_ParseTuple only accepts positional-only arguments, and anything 
that calls it more than once probably has some optional arguments.

Run from a fresh Python trunk:

    % fgrep -w PyArg_ParseTuple */*.c | wc
         861    4728   69716



//arry/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20131009/090699f2/attachment.html>


More information about the Python-Dev mailing list