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

Sven R. Kunze srkunze at mail.de
Fri Aug 5 17:03:55 EDT 2016


On 05.08.2016 18:41, Guido van Rossum wrote:
> I considered that, but before allowing that complexity, I think we
> should come up with a compelling use case (not a toy example). This
> also produces some surprising behavior, e.g. what would the following
> do:
>
> def foo():
>      T = List[int]
>      a: T = []
>      # etc.
>
> If we evaluate the annotation `T` in the surrounding scope, it would
> be a NameError, but a type checker should have no problem with this
> (it's just a local type alias).

Will arbitrary expressions work or only type declarations?

a: <expression>


I am asking because https://www.python.org/dev/peps/pep-3107/#parameters 
is not limited to types.


--
Sven


More information about the Python-ideas mailing list