Raw Strings with Variables

Terry Reedy tjreedy at udel.edu
Wed Aug 19 06:52:14 EDT 2009


WilsonOfCanada wrote:
> Hellos,
> 
> I know that if you have:
> 
> happy = r"C:\moo"
> print happy
> 
> you get C:\moo instead of C:\\moo
> 
> The thing is that I want to do this a variable instead.
> 
> ex. testline = fileName.readline()
>       rawtestline = r testline

Python does not have 'raw strings'. It only has 'raw string literals', 
which is to say, string literals with 'r' prepended to signal less 
processing (cooking) of the literal in the process of turning it into a 
string object.

tjr




More information about the Python-list mailing list