raw strings and \

Steve Holden steve at holdenweb.com
Mon Mar 6 03:24:34 CET 2006

plahey at alumni.caltech.edu wrote:
> Hi,
> thanks for the reply.  I was not aware of this in raw strings (and
> frankly, don't like it... but who cares about that :-) )
Healthy attitude!

> When I needed embedded quotes in a raw string I went the triple quote
> route:
> a = r'''check \' this'''
> which makes more sense to me.
But remember you could equally well have used

a = "check \\' this"

I presume you do *want* that backslash in there? If not, of course, then

a = "check ' this"

is by far the simplest way to represent what you want. because Python 
offers four different string quotes, each of which can be raw, there's 
always a way ...

Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd                 www.holdenweb.com
Love me, love my blog         holdenweb.blogspot.com

More information about the Python-list mailing list