[Python-Dev] Formatting of positional-only parameters in signatures (original) (raw)
Yury Selivanov yselivanov.ml at gmail.com
Tue Jan 21 16:59:36 CET 2014
- Previous message: [Python-Dev] Argument Clinic: Bug? self converters are not preserved when cloning functions
- Next message: [Python-Dev] Formatting of positional-only parameters in signatures
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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(, , baz)
“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:
Leave it as is. Obviously, the downside is the potential confusion with “optional” notation.
Adopt PEP 457 style: using “/“ to separate positional-only parameters from the rest.
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.
Thoughts?
Yury
- Previous message: [Python-Dev] Argument Clinic: Bug? self converters are not preserved when cloning functions
- Next message: [Python-Dev] Formatting of positional-only parameters in signatures
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]