It seems that some escape chars still matter in docstring. For example, if we run python foo.py (Python 2.7.10), it will emit error like ValueError: invalid \x escape.
def f():
"""
do not deal with '\x0'
"""
pass
And in effect, it seem the correct docsting should be:
"""
do not deal with '\\\\x0'
"""
Additionally it also affects import.
For Python 3.4.3+, the error message is:
File "foo.py", line 4
"""
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 24-25: truncated \xXX escape
I feel it a bit strange since I was thinking it would only affect __doc__ and have no side effect on the module itself.
Why designed to be so? Is it a flaw/bug in Python?
NOTE
I know the meaning of """ and raw literals, however I think python interpreter should be able to treat docstring specially, at least in theory.