pep8 warning on regex string in Python, Eclipse pep8 warning on regex string in Python, Eclipse python python

pep8 warning on regex string in Python, Eclipse


"\d" is same as "\\d" because there's no escape sequence for d. But it is not clear for the reader of the code.

But, consider \t. "\t" represent tab chracter, while r"\t" represent literal \ and t character.

So use raw string when you mean literal \ and d:

re.compile(r"\d{3}")

or escape backslash explicitly:

re.compile("\\d{3}")


Python is unable to parse '\d' as an escape sequence, that's why it produces a warning.

After that it's passed down to regex parser literally, works fine as an E.S. for regex.