<p dir="ltr"><br>
On 22 Jan 2014 03:24, "Terry Reedy" <<a href="mailto:tjreedy@udel.edu">tjreedy@udel.edu</a>> wrote:<br>
><br>
> On 1/21/2014 10:59 AM, Yury Selivanov wrote:<br>
>><br>
>> There is one more, hopefully last, open urgent question with the signature<br>
>> object. At the time we were working on the PEP 362, PEP 457 didn’t<br>
>> exist. Nor did we have any function with real positonal-only parameters,<br>
>> since there was no Argument Clinic yet. However, I implemented<br>
>> rudimentary support for them:<br>
>><br>
>> “Parameter.POSITIONAL_ONLY” constant;<br>
>><br>
>> “Signature.bind” and “Signature.bind_partial” fully support functions<br>
>> with positional-only parameters;<br>
>><br>
>> “Signature.__str__” renders them distinctively from other kinds.<br>
>><br>
>> The last point is the troublesome now. "Signature.__str__” renders<br>
>> positional-only parameters in ‘<>’ brackets, so in:<br>
>><br>
>> foo(<ham>, <spam>, baz)<br>
><br>
><br>
> This amounts to a hidden new API.<br>
><br>
><br>
>> “ham” and “spam” are positional-only. The choice of angle brackets was<br>
>> unfortunate, as, first of all, this wasn’t really discussed on<br>
>> python-dev, and second, it’s easy to think that those parameters are<br>
>> optional.<br>
>><br>
>> Now, with the AC landing in 3.4, we need to decide how positional-only<br>
>> parameters will look like.<br>
>><br>
>> Without starting a new discussion similar to what we had prior to PEP 457,<br>
>> I think we have three options:<br>
>><br>
>> 1. Leave it as is. Obviously, the downside is the potential confusion<br>
>> with “optional” notation.<br>
><br>
><br>
> 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.</p>
<p dir="ltr">It was the "we have to do something about this" short term fix we implemented for 3.3, that hasn't caused major problems due to the difficulties of creating such signatures in the first place. Argument Clinic changes that, since a variety of C level callables with this kind of signature will know be handled by the inspect module.</p>

<p dir="ltr">I think it's actually tolerable to leave this in place for 3.4 as well, although I'd prefer to instead bring it into line with Argument Clinic.</p>
<p dir="ltr">>> 2. Adopt PEP 457 style: using “/“ to separate positional-only parameters<br>
>> from the rest.<br>
><br>
><br>
> I think this is what Larry proposed, but Nick opposed as a post-beta new feature.</p>
<p dir="ltr">No, I think this is a good idea. It matches previous discussions with Guido and is more consistent with Argument Clinic.</p>
<p dir="ltr">The exchange between me and Larry was about the more exotic signatures like range() that inspect.Signature currently can't even represent internally - handling *those* requires changes to the data model and public API of inspect.Signature, not just the string representation.</p>

<p dir="ltr">By contrast, positional only parameter support is already there, it's just that the notation used in the string representation is inconsistent with Argument Clinic's notation.</p>
<p dir="ltr">>> 3. Don’t use any notation, just render them as plain arguments:<br>
>> "foo(ham, spam, baz)". The downside here is that the users will be<br>
>> confused, and might try passing those parameters with keywords, or<br>
>> binding them with keywords.<br>
><br>
><br>
> 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</p>
<p dir="ltr">We already rejected this option when inspect.Signature was first added. I don't see a good reason to reverse that decision now.</p>
<p dir="ltr">> (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.</p>
<p dir="ltr">That's (at least in part) what PEP 457 was about - documenting the format Guido had already given lukewarm approval to. It's the basis of Argument Clinic's syntax, and currently illegal Python syntax.</p>

<p dir="ltr">Cheers,<br>
Nick.</p>
<p dir="ltr">><br>
> -- <br>
> Terry Jan Reedy<br>
><br>
><br>
><br>
> _______________________________________________<br>
> Python-Dev mailing list<br>
> <a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/python-dev">https://mail.python.org/mailman/listinfo/python-dev</a><br>
> Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com">https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com</a><br>
</p>