[Python-ideas] PEP 8: raw strings & regular expressions

Ryan Gonzalez rymg19 at gmail.com
Wed Oct 21 22:52:42 EDT 2015



On October 21, 2015 9:24:02 PM CDT, Yury Selivanov <yselivanov.ml at gmail.com> wrote:
>Hi,
>
>I was a little bit frustrated that Sublime Text and Atom didn't support
>all Python 3 features (mainly annotations & async/await syntax), so I
>decided to write a new highlighter:
>
>     https://github.com/MagicStack/MagicPython
>

Now see if you can get the Linguist guys to use it! :) Every time I look at the Fbuild source online, my eyes sting due to the lack of annotation support in language-python, which screws up highlighting for a bit:

https://github.com/felix-lang/fbuild/blob/master/lib/fbuild/builders/c/gcc/__init__.py#L436 - Keywords aren't highlighted for several lines.

Or:

https://github.com/felix-lang/fbuild/blob/master/lib/fbuild/builders/bison.py#L15

Where almost (but not quiet) everything is un-highlighted! :O

>In the process, we had to make a decision on how to highlight raw
>string
>literals -- r''.  Many existing highlighters assume that all raw
>strings
>are regexps, and highlight them as such, i.e. '\s' and '\n' will be
>highlighted.
>
>I think that it might be a good idea to state the following in PEP 8:
>
>- use r'...' strings for raw strings that describe regular expressions;
>these strings might be highlighted specially in some editors.
>
>- use R'...' strings for raw strings; editors *should not* highlight
>any escaped characters in them.
>
>What do you think?
>
>Yury
>
>_______________________________________________
>Python-ideas mailing list
>Python-ideas at python.org
>https://mail.python.org/mailman/listinfo/python-ideas
>Code of Conduct: http://python.org/psf/codeofconduct/

-- 
Sent from my Nexus 5 with K-9 Mail. Please excuse my brevity.


More information about the Python-ideas mailing list