syntax difference

Schachner, Joseph Joseph.Schachner at Teledyne.com
Mon Jun 18 10:58:29 EDT 2018


As soon as I sent the previous message I realized it's "doc string" not def string.  Pardon me. 
--- Joe S.

-----Original Message-----
From: Ed Kellett <e+python-list at kellett.im> 
Sent: Monday, June 18, 2018 8:47 AM
To: python-list at python.org
Subject: Re: syntax difference

On 2018-06-18 13:18, Chris Angelico wrote:
> 1) Parse the code, keeping all the non-essential parts as well as the 
> essential parts.
> 2) Find the comments, or find the annotations
> 3) If comments, figure out if they're the ones you want to remove.
> 4) Reconstruct the file without the bits you want to remember.
> 
> Step 3 is removed if you're using syntactic annotations. Otherwise, 
> they're identical.

It's likely that Python comments are much easier to remove than arbitrary bits of Python syntax--you need to know the answer to "am I in a string literal?", which is a lexical analysis problem you could hack together a solution for over the course of about one coffee, as opposed to "where exactly am I in the Python parse tree?", which is... harder.
The information you need to keep track of and later reconstruct is substantially simpler, too.

I don't think "they're hard to mechanically remove" is a particularly good argument against type hints, but considered on its own it probably is true.



More information about the Python-list mailing list