<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix"><br>
<br>
On 01/17/2018 08:29 AM, Ethan Furman wrote:<br>
</div>
<blockquote type="cite" cite="mid:5A5F79DC.7080407@stoneleaf.us">On
01/17/2018 08:14 AM, Serhiy Storchaka wrote:
<br>
<blockquote type="cite">17.01.18 16:34, Victor Stinner пише:
<br>
<blockquote type="cite">In Februrary 2017, I proposed on
python-ideas to change the Python
<br>
syntax to allow to declare positional-only parameters in
Python:
<br>
<br>
<a class="moz-txt-link-freetext" href="https://mail.python.org/pipermail/python-ideas/2017-February/044879.html">https://mail.python.org/pipermail/python-ideas/2017-February/044879.html</a>
<br>
<a class="moz-txt-link-freetext" href="https://mail.python.org/pipermail/python-ideas/2017-March/044956.html">https://mail.python.org/pipermail/python-ideas/2017-March/044956.html</a>
<br>
</blockquote>
<br>
The main problem -- designing a syntax that does not look ugly.<br>
</blockquote>
<br>
The syntax question is already solved:
<br>
<br>
def some_func(a, b, /, this, that, *, the_other):
<br>
# some stuff
<br>
<br>
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. ;)</blockquote>
<br>
To clarify: this is the syntax used by "Argument Clinic", both as
its input language, and as part of its output, exposed via the
__text_signature__ attribute on builtins.<br>
<br>
Why did Argument Clinic choose that syntax? It was suggested by one
Guido van Rossum in March 2012:<br>
<blockquote><a class="moz-txt-link-freetext" href="https://mail.python.org/pipermail/python-ideas/2012-March/014364.html">https://mail.python.org/pipermail/python-ideas/2012-March/014364.html</a><br>
<a class="moz-txt-link-freetext" href="https://mail.python.org/pipermail/python-ideas/2012-March/014378.html">https://mail.python.org/pipermail/python-ideas/2012-March/014378.html</a><br>
<a class="moz-txt-link-freetext" href="https://mail.python.org/pipermail/python-ideas/2012-March/014417.html">https://mail.python.org/pipermail/python-ideas/2012-March/014417.html</a><br>
</blockquote>
<br>
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 "/".<br>
<br>
<br>
<br>
Would we be adding yet a third argument-parsing function,
PyArg_ParseTupleAndKeywordsWithPositionalOnly()? I would actually
propose a different approach: modify Argument Clinic so it generates
custom argument-parsing code for each function, adding a new call
type (which I propose calling "METH_RAW" or "METH_STACK") where the
stack is passed in directly. I spent some time on this in the past,
though I got distracted and now haven't touched it in years.<br>
<br>
<br>
<br>
Cheers,<br>
<br>
<br>
<i>/arry</i><br>
</body>
</html>