[Python-Dev] PEP 484: updates to Python 2.7 signature syntax

Guido van Rossum guido at python.org
Mon Mar 21 17:11:12 EDT 2016


This seemed pretty uncontroversial -- I've updated the PEP (including
a long(ish) example :-).

On Sat, Mar 19, 2016 at 6:54 PM, Guido van Rossum <guido at python.org> wrote:
> Heh. I could add an example with a long list of parameters with long
> names, but apart from showing by example what the motivation is it
> wouldn't really add anything, and it's more to type. :-)
>
> On Sat, Mar 19, 2016 at 6:43 PM, Andrew Barnert <abarnert at yahoo.com> wrote:
>> On Mar 19, 2016, at 18:18, Guido van Rossum <guido at python.org> wrote:
>>>
>>> Second, https://github.com/python/typing/issues/186. This builds on
>>> the previous syntax but deals with the other annoyance of long
>>> argument lists, this time in case you *do* care about the types. The
>>> proposal is to allow writing the arguments one per line with a type
>>> comment on each line. This has been implemented in PyCharm but not yet
>>> in mypy. Example:
>>>
>>>    def gcd(
>>>            a,  # type: int
>>>            b,  # type: int
>>>            ):
>>>        # type: (...) -> int
>>>        <code here>
>>
>> This is a lot nicer than what you were originally discussing (at #1101? I forget...). Even more so given how trivial it will be to mechanically convert these to annotations if/when you switch an app to pure Python 3.
>>
>> But one thing: in the PEP and the docs, I think it would be better to pick an example with longer parameter names. This example shows that even in the worst case it isn't that bad, but a better example would show that in the typical case it's actually pretty nice. (Also, I don't see why you wouldn't just use the "old" comment form for this example, since it all fits on one line and isn't at all confusing.)
>>
>
>
>
> --
> --Guido van Rossum (python.org/~guido)



-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list