syntax difference

Chris Angelico rosuav at gmail.com
Sun Jun 17 16:27:10 EDT 2018


On Mon, Jun 18, 2018 at 4:10 AM, Rick Johnson
<rantingrickjohnson at gmail.com> wrote:
> 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?

You're absolutely right. We should eliminate the 'assert' keyword
(since the interpreter can and does ignore assertions in optimized
mode), comments, and blank lines. Anyone with half a brain will see at
once that they should obviously be removed. Anyone with an entire
brain, of course, will appreciate them.

>> 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!

Huh. Funny you should say that.

https://www.python.org/dev/peps/pep-0484/#type-comments

ChrisA



More information about the Python-list mailing list