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

Alexander Belopolsky alexander.belopolsky at gmail.com
Thu Aug 4 11:40:47 EDT 2016


On Thu, Aug 4, 2016 at 11:22 AM, Guido van Rossum <gvanrossum at gmail.com> wrote:
> However the presence of a local declaration like 'a: int' would create a
> local slot for 'a' as if it were assigned to somewhere in the function.

Does this mean that the following code will raise a NameError?

a = None
def f():
  a: int
  a

(FWIW, I like the <var>: <type> notation more than any alternative
proposed so far.)


More information about the Python-ideas mailing list