[Python-Dev] Positional-only parameters in Python (original) (raw)

Victor Stinner victor.stinner at gmail.com
Thu Jan 18 06:12:40 EST 2018


2018-01-18 10:26 GMT+01:00 Larry Hastings <larry at hastings.org>:

Why did Argument Clinic choose that syntax? It was suggested by one Guido van Rossum in March 2012: (...) I'm not wading into the debate over what syntax Python should use if it adds positional-only parameters, except to say that I think "/" is reasonable. If Python winds up using a different syntax, I'd look into modifying Argument Clinic so that it accepts both this hypothetical new syntax and the existing syntax using "/".

The "/" syntax is used since Python 3.5, at least in some function docstrings:

$ python3.5 Python 3.5.4+ (heads/3.5:fd8614c5c5, Dec 18 2017, 12:53:10)

help(abs) Help on built-in function abs in module builtins:

abs(x, /) Return the absolute value of the argument.

inspect.signature() is able to parse this syntax, but currently, it is only used to parse text_signature attribute of builtin functions.

Victor



More information about the Python-Dev mailing list