How to write string literals in Python without having to escape them?

escaping, python, rawstring, string

Solution

Raw string literals:

>>> r'abc\dev\t'
'abc\\dev\\t'

Problem

Is there a way to declare a string variable in Python such that everything inside of it is automatically escaped, or has its literal character value? I'm not asking how to escape the quotes with slashes, that's obvious. What I'm asking for is a general purpose way for making everything in a string literal so that I don't have to manually go through and escape everything for very large strings.

Original source

Related problems