[Python-Dev] PEP 484: updates to Python 2.7 signature syntax
Andrew Barnert
abarnert at yahoo.com
Sat Mar 19 21:43:32 EDT 2016
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.)
More information about the Python-Dev
mailing list