anomalous-backslash-in-string / W1401ΒΆ
Message emitted:
Anomalous backslash in string: '%s'. String constant might be missing an r prefix.
Description:
Used when a backslash is in a literal string but not as an escape.
Problematic code:
string = "\z" # [anomalous-backslash-in-string]
Correct code:
double_escape.py
:
string = "\\z"
existing_escape_sequence.py
:
string = "\t"
r_prefix.py
:
string = r"\z"
Additional details:
\z
is same as \\z
because there's no escape sequence for z
. But it is not clear
for the reader of the code.
Related links:
Created by the string checker.