Barry Warsaw writes:

 > On Aug 17, 2015, at 11:02 AM, Paul Moore wrote:
 > 
 > >    print(f"Iteration {n}: Took {end-start) seconds")
 > 
 > This illustrates (more) problems I have with arbitrary expressions.
 > 
 > First, you've actually made a typo there; it should be
 > "{end-start}" -- notice the trailing curly brace.  Second, what if
 > you typoed that as "{end_start}"?  According to PEP 498 the
 > original typo above should trigger a SyntaxError

That ship has sailed, you have the same problem with str.format format
strings already.

 > and the second a run-time error (NameError?).

Ditto.

 > But how will syntax highlighters and linters help you discover your
 > bugs before you've even saved the file?

They need to recognize that a string prefixed with "f" is special,
that it's not just a single token, then parse the syntax.  The hardest
part is finding the end-of-string delimiter!  The expression itself is
not a problem, since either we already have the code to handle the
expression, or we don't (and your whole point is moot).

Emacs abandoned the idea that you should do syntax highlighting without
parsing well over a decade ago.  If Python can implement the syntax,
Emacs can highlight it.  It's just a question of if there's will to do
it on the part of the python-mode maintainers.

I'm sure the same can be said about other linters and highlighters for
Python, though I have no part in implementing them.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to