Windows 10 with Python 3.12 in a virtual environment.
I have a docstring at the beginning of my program, before any imports or code, it looks like this. This is a test program to show the error.
'''This is a test program. Put file in c:\users\me\stuff.
Regex is stuff/morestuff/print\d+
'''
I get a syntax error:
File "C:\Users\me\OneDrive - coname\Documents\PythonProjects\blah\Buscard\testdoc.py", line 1
'''
^^^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 15-16: truncated \uXXXX escape
Here’s the error. SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 15-16: truncated \uXXXX escape
I assumed docstrings are treated like comments, but I was wrong. How do I get rid of this error? I have windows paths and regex documented in all kinds of programs using the backslash.
I was using docstrings as comments. Does Python have true multi-line comments where I won’t get a syntax error when I type in a windows dir with backslashes, or when I type in regex meta characters?
EDIT: I actually need multi-line comments as comments in the beginning of the program document many things all in one place, and the comments do tend to change early in the programming process. Getting the end user to decide on specs and stick with it is not possible.
In Perl I enclosed this documentation in POD documentation blocks.