[Python-ideas] Trial balloon: adding variable type declarations in support of PEP 484

Brendan Barnwell brenbarn at brenbarn.net
Tue Aug 2 01:25:48 EDT 2016


On 2016-08-01 15:58, Guido van Rossum wrote:
> The problem with this is that the relative priorities of '=' and ','
> are inverted between argument lists and assignments. And the
> expression on the right might be a single variable whose type is a
> tuple. So we'd get
>
> a: int, b: str = x
>
> But the same thing in a function definition already has a different meaning:
>
> def foo(a: int, b: str = x): ...

	Is that really a big deal?  Insofar as it's a problem, it already 
exists for function arguments vs. assignments without any type 
annotation.  That is:

a, b = x

already means something different from

def foo(a, b = x): ...

	So in one sense, keeping type annotations with the variables would 
actually maintain the current convention (namely, that assignment and 
argument defaults have different conventions).

-- 
Brendan Barnwell
"Do not follow where the path may lead.  Go, instead, where there is no 
path, and leave a trail."
    --author unknown


More information about the Python-ideas mailing list