syntax difference

Rick Johnson rantingrickjohnson at gmail.com
Sun Jun 17 14:10:55 EDT 2018


Steven D'Aprano wrote:
> Bart Wrote:
> > So what's a Type Hint associated with in Python?
> Since it is a type *hint*, not a type *declaration*, the
> interpreter can and does ignore it.

But yet, the _programmer_ cannot ignore it. Does that make
any sense to you, or anyone else with half a brain?

> It makes no change at all to the execution model of the
> language.

Then why the *HELL* are type-hints an official part of the
Python language syntax? Had type hints been implemented as
comments (for instance: a special class of comment in the
same way that doc-strings are a special class of strings),
then a programmer could ignore them! Heck, i have even have
a feature in my editor that will hide all comments and doc-
strings! And the code to perform this task is fairly simple.

But it's gonna one hell of a _nightmare_ to remove type-
hints from source code when they are _interleaved_ with the
damn source code, and considered by the interpreter to be
syntax.

> But the human reader, linters, IDEs and editors can
> associate it with the name it annotates, and use it as a
> hint as to what is intended to happen, and flag any
> discrepancies.

And each of these could have done the same with a "type-hint
comment". But oh no, that would be too easy! And the whole
point here is to cause a big fat ruckus? Isn't it, Mr.
D'Aprano?







More information about the Python-list mailing list