Newbie question - what is the 'r' operator?

Fredrik Lundh effbot at telia.com
Tue Feb 8 03:11:33 EST 2000


Craig Findlay <craigf at ilid.com.au> wrote:
> This is probably obvious but ...
>
> I have seen example code where an 'r' prefix is used in from of a
> string, eg r'mystring'
>
> What does it do, I can't seem to locate any documentation about it.

    http://www.python.org/doc/current/ref/strings.html

    "When an 'r' or 'R' prefix is present, backslashes
    are still used to quote the following character,
    but all backslashes are left in the string."

(useful when embedding all sorts of cryptic sublanguages in
python strings, such as regular expressions or windows file
names...)

</F>





More information about the Python-list mailing list