r strings?

Greg Jorgensen gregj at pobox.com
Sun Nov 19 13:59:25 EST 2000


<johnvert at my-deja.com> wrote in message news:8v95f5$mg1$1 at nnrp1.deja.com...
> Hey,
>
> Simple question: what does it mean when strings begin with the letter
> 'r'?

The r means raw: backslash characters are not translated as escapes. You
often see the r'...' form in regular expressions:

regex = re.compile(r'johnvert at my-deja\.com')   # regex to match your email
address

You can get the same effect by double-escaping but it's not as clear:

r'foo\.bar'  is the same as 'foo\\.bar'

--
Greg Jorgensen
Deschooling Society
Portland, Oregon, USA
gregj at pobox.com





More information about the Python-list mailing list