from string to raw string

Brian Beck exogen at gmail.com
Mon Dec 13 23:30:01 EST 2004


Dan Perl wrote:
> Is there a way to convert a regular string to a raw string so that one could 
> get from '\bblah' to r'\bblah' other than parsing the string and modifying 
> the escapes?

There's no such thing as a raw string, only raw string literals. In 
other words, it's a syntax to tell the Python interpreter which 
characters in your string are 'special' and has no effect on strings not 
input as literals directly within your code.  Strings from files or any 
input besides the interactive Python shell will already be what you're 
looking for.

-- 
Brian Beck
Adventurer of the First Order



More information about the Python-list mailing list