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

Yury Selivanov yselivanov.ml at gmail.com
Wed Oct 21 23:22:05 EDT 2015



On 2015-10-21 10:58 PM, Ryan Gonzalez wrote:
> On October 21, 2015 9:53:05 PM CDT, Yury Selivanov<yselivanov.ml at gmail.com>  wrote:
>> >On 2015-10-21 10:44 PM, Ben Finney wrote:
>>>>> >>> >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.
>>> >>That is evidently a simple mistake. Merely knowing that a token is a
>> >raw
>>> >>string does not justify the assumption that the string is a regular
>>> >>expression, or a filesystem entry name, or a line in a network
>> >protocol,
>>> >>or anything except plain text.
>> >
>> >I agree 100%.
>> >
>> >But: github, gitlab, Atom, Sublime Text, and many other tools
> GitHub and Atom both use language-python.
>

Yeah.  I even created a PR to use MagicPython in language-python
a few days ago.

BTW, here's a link to github to show how raw strings are highlighted:
https://github.com/python/cpython/blob/master/Lib/_pydecimal.py#L6087

Yury


More information about the Python-ideas mailing list