[py-usr] flake8 gives me a W605 but Python don't

Reto reto at labrat.space
Sat Sep 10 15:41:04 EDT 2022


On Sat, Sep 10, 2022 at 06:46:33PM +0000, c.buhtz at posteo.jp wrote:
> 
> But running this with Python 3.9.2 makes no problem. Python doesn't
> give me a `SyntaxWarning` or anything else. Python doesn't give me an
> error or warning. Only `flymake8` gives me this error.

Well, it's not a syntax error.
Escape sequences with no meaning simply yield the escape sequence.

As in, '\d' is simply '\d', in contrast  with say '\u' which is invalid
and if fact throws a SyntaxError.


>Unlike Standard C, all unrecognized escape sequences are left in the string unchanged, i.e., the backslash is left in the result. (This behavior is useful when debugging: if an escape sequence is mistyped, the resulting output is more easily recognized as broken.) It is also important to note that the escape sequences only recognized in string literals fall into the category of unrecognized escapes for bytes literals.

from https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals


More information about the Python-list mailing list