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

Ethan Furman ethan at stoneleaf.us
Wed Jan 17 11:29:16 EST 2018


On 01/17/2018 08:14 AM, Serhiy Storchaka wrote:

17.01.18 16:34, Victor Stinner пише:

In Februrary 2017, I proposed on python-ideas to change the Python syntax to allow to declare positional-only parameters in Python:

https://mail.python.org/pipermail/python-ideas/2017-February/044879.html https://mail.python.org/pipermail/python-ideas/2017-March/044956.html The main problem -- designing a syntax that does not look ugly. I think there are too small time is left before features freezing for experimenting with it. It would be better to make such changes at the early stage of development.

The syntax question is already solved:

def some_func(a, b, /, this, that, *, the_other):
    # some stuff

Everything before the slash is positional-only, between the slash and star is positional-or-keyword, and after the star is keyword-only. This is what is in our generated help(), and there is a nice symmetry between '/' and '*' being opposites, and positional/keyword being opposites. And slash is certainly no uglier than star. ;)

-- Ethan



More information about the Python-Dev mailing list