[Python-ideas] Trial balloon: adding variable type declarations in support of PEP 484
Guido van Rossum
guido at python.org
Wed Aug 3 21:58:14 EDT 2016
On Wed, Aug 3, 2016 at 5:52 PM, Steven D'Aprano <steve at pearwood.info> wrote:
[...]
> result: Type = undef
>
> would be a no-op at runtime, but the type-checker could take the
> type-hint from it. There's no actual "undef" value. If you followed that
> line by:
>
> print(result)
>
> you would get a NameError, same as today.
[...]
Thanks for explaining my use case so well (in the text I snipped).
However, I still feel that just
result: Type
is the better alternative. Syntactically there's no problem with it.
It doesn't require a new `undef` keyword or constant, and it doesn't
make people think there's an `undef` value. As you mentioned, this has
been an unmitigated disaster in JS.
--
--Guido van Rossum (python.org/~guido)
More information about the Python-ideas
mailing list