Collin Funk wrote:
> > I guess I wasn't very familiar with raw strings when I did this change.
> 
> No worries, it was pretty easy to find and fix. I remember a professor
> in college telling us to always use them for Python regular
> expressions. It seems this is also recommended by the Python people,
> see the '\' character under this page:
> 
> https://docs.python.org/3/library/re.html#regular-expression-syntax

Indeed, this doc contains the explanation for the 'pycodestyle'
warning that I was seeing. With a plain string instead of a raw string,
I get:

$ pycodestyle *.py
...
GLEmiter.py:535:26: W605 invalid escape sequence '\.'
GLEmiter.py:535:35: W605 invalid escape sequence '\.'
...

which indicates that the Python parser would have eaten up the backslash
before the regular expression engine could see it.

Bruno




Reply via email to