Python Literal r'\' Not Accepted

r'\' in Python does not work as expected. Instead of returning a string with one character (a backslash) in it, it raises a SyntaxError. r"\" does the same.
This is rather cumbersome if you have a list of Windows paths like these:
paths = [ r'\bla\foo\bar',
          r'\bla\foo\bloh',
          r'\buff',
          r'\',
          # ...
        ]
Is there a good reason why this literal is not accepted?

Комментарии

Популярные сообщения из этого блога

Unable to construct Application instance [duplicate]

What is considered 'insulting a Muslim'? And is it a sin? If so, is it a minor or major scene?