r"string" vs R"string

Ben Finney ben+python at benfinney.id.au
Sun Jan 17 02:14:27 EST 2010


Brendan Miller <catphive at catphive.net> writes:

> Is there any difference whatsoever between a raw string beginning with
> the captical R or one with the lower case r e.g. r"string" vs
> R"string"?

For answering questions like this, the Python language reference is your
friend:

    String literals may optionally be prefixed with a letter 'r' or 'R';
    such strings are called raw strings and use different rules for
    interpreting backslash escape sequences.

    <URL:http://docs.python.org/reference/lexical_analysis.html#string-literals>.

No mention is made of any distinction made between ‘r’ or ‘R’ in this
context.

-- 
 \       “Give a man a fish, and you'll feed him for a day; give him a |
  `\    religion, and he'll starve to death while praying for a fish.” |
_o__)                                                       —Anonymous |
Ben Finney



More information about the Python-list mailing list