[Tutor] Quick question,

Noufal Ibrahim noufal at nibrahim.net.in
Fri Apr 7 18:19:09 CEST 2006

On Fri, April 7, 2006 8:23 pm, Carlos Benevides wrote:
> Hi,
> Can someone tell me what the r before the expression means, as in
> "re.compile(r'(\.exe|\.zip|\.pif|\.scr|\.ps|\.pdf|\.ppt)$')"?

r is the way of making a string "raw". This means that escape characters
will not be interpreted. Here is an example that should make it clear.

>>> foo = "This is \t me"
>>> print foo
This is          me
>>> foo = r"This is \t me"
>>> print foo
This is \t me

Since slashes are used often for writing regexps, it's useful to make the
strings raw.



More information about the Tutor mailing list