[Python-Dev] Formatting of positional-only parameters in signatures

Terry Reedy tjreedy at udel.edu
Tue Jan 21 18:22:13 CET 2014

On 1/21/2014 10:59 AM, Yury Selivanov wrote:
> There is one more, hopefully last, open urgent question with the signature
> object. At the time we were working on the PEP 362, PEP 457 didn’t
> exist. Nor did we have any function with real positonal-only parameters,
> since there was no Argument Clinic yet. However, I implemented
> rudimentary support for them:
> “Parameter.POSITIONAL_ONLY” constant;
> “Signature.bind” and “Signature.bind_partial” fully support functions
> with positional-only parameters;
> “Signature.__str__” renders them distinctively from other kinds.
> The last point is the troublesome now. "Signature.__str__” renders
> positional-only parameters in ‘<>’ brackets, so in:
> foo(<ham>, <spam>, baz)

This amounts to a hidden new API.

> “ham” and “spam” are positional-only. The choice of angle brackets was
> unfortunate, as, first of all, this wasn’t really discussed on
> python-dev, and second, it’s easy to think that those parameters are
> optional.
> Now, with the AC landing in 3.4, we need to decide how positional-only
> parameters will look like.
> Without starting a new discussion similar to what we had prior to PEP 457,
> I think we have three options:
> 1. Leave it as is. Obviously, the downside is the potential confusion
> with “optional” notation.

I think this this is bad, as it has not been discussed and agreed on, 
and might be changed. It is a plausible alternative to '/', but might 
possibly even have been rejected. I do not remember.

> 2. Adopt PEP 457 style: using “/“ to separate positional-only parameters
> from the rest.

I think this is what Larry proposed, but Nick opposed as a post-beta new 

> 3. Don’t use any notation, just render them as plain arguments:
> "foo(ham, spam, baz)". The downside here is that the users will be
> confused, and might try passing those parameters with keywords, or
> binding them with keywords.

This is the status quo for the docs (both notation and occasional 
confusion). I think signature should match until we agree on a new 
convention (and I think one is needed). The first thing to decide is 
whether to mark each position-only parameter or to put one marker after 
all of them.

Terry Jan Reedy

More information about the Python-Dev mailing list