[Python-ideas] Delay evaluation of annotations

אלעזר elazarg at gmail.com
Sun Sep 25 14:54:21 EDT 2016


On Sun, Sep 25, 2016 at 9:28 PM David Mertz <mertz at gnosis.cx> wrote:

> On Sep 25, 2016 10:59 AM, "אלעזר" <elazarg at gmail.com> wrote:
> > 2. It is not naturally supported by syntax highlighters and IDEs. They
> can be made to support it, but most will not.
>
> This is a complete red herring. Having a highlight rule of "apply
> highlights in string annotations" is straightforward in modern editors.
> This is like arguing Python should do <whatever> because Notepad.exe
> doesn't do something smart with it.
>

Not that I think it's a killer argument, but why a red herring? Quick
search does not find such an explicit option in Gedit, PyDev and yes,
Notepad++.exe. It is not a common or default option.

Having such a rule by default amounts to admitting that these are not
essentially strings, and the quotes there are overloaded. It also means
that actual strings are not understood as such, and are incorrectly
highlighted. But please let's not delve into this: it is of some
importance, but should not affect an actual decision.

IDEs are more important. Renaming facilities do over-renaming or
under-renaming because of this need to rename inside some strings, but not
inside others. Similarly code search facilities, and warnings from IDEs
about inlining variables. I have encountered real bugs caused by such an
imperfect renaming (and I hope your answer is not "don't do renaming").

A prefix like

  code"foo()"

might help of course, but it is not really used as a string.

Elazar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160925/d42e8522/attachment.html>


More information about the Python-ideas mailing list