syntax difference

Chris Angelico rosuav at gmail.com
Mon Jun 18 13:46:09 EDT 2018


On Tue, Jun 19, 2018 at 3:34 AM, Jim Lee <jlee54 at gmail.com> wrote:
>
>
> On 06/18/2018 07:03 AM, Steven D'Aprano wrote:
>>
>> As a human programmer, you surely perform your own ad hoc type checking
>> when you write and debug code.
>
> Of course.  And, I use linting tools and other forms of static type
> checking.  What I don't like is adding the *syntax* for static type checking
> to the (dynamically typed) language proper, particularly when the
> implementations of said language do nothing but ignore it.

So you have annotations for type information. Tell me: why should
these annotations be introduced with a hash and ended with a newline?
What is it about type annotations that requires that they be delimited
in this way?

What about assertions? Are they comments too? Should we have, for instance:

if x > 0:
    ...
elif x < 0:
    ...
else:
    #assert: x == 0
    ...

or is it better to use an 'assert' statement? After all, they can
legitimately be ignored by the interpreter.

ChrisA



More information about the Python-list mailing list