Given the following python script:
# dedupe.py
import re
def dedupe_whitespace(s,spacechars=\'\\t \'):
\"\"\"Merge repeated whitespace characters.
Examp
TL;DR: Escape the backslash, i.e., use \\n
or \\t
instead of \n
or \t
in your otherwise unmodified strings;
You probably don't want to make your docstrings raw as then you won't be able to use any Python string escapes including those you might want to.
For a method that supports using normal escapes, just escape the backslash in the backslash-character escape so after Python interprets it, it leaves a literal backslash followed by the character which doctest
can parse.