Raw Unicode docstring

B

Boštjan Mejak

Hello,

how does one write a raw unicode docstring? If I have backslashes in
the docstring, I must tuck an 'r' in front of it, like this:
r"""This is a raw docstring."""

If I have foreign letters in the docstring, I must tuck a 'u' in front
of it, like this:
u"""This is a Unicode docstring."""

What if I have foreign characters *and* backslashes in my docstring?
How to write the docstring then?
ru"""My raw unicode docstring."""
or
ur"""My unicode docstring."""

Please answer my question, although it may sound like a noobish one. Thanks.
 
R

RJB

Hello,

how does one write a raw unicode docstring? If I have backslashes in
the docstring, I must tuck an 'r' in front of it, like this:
r"""This is a raw docstring."""

If I have foreign letters in the docstring, I must tuck a 'u' in front
of it, like this:
u"""This is a Unicode docstring."""

What if I have foreign characters *and* backslashes in my docstring?
How to write the docstring then?
ru"""My raw unicode docstring."""
or
ur"""My unicode docstring."""

Please answer my question, although it may sound like a noobish one. Thanks.

Check out
http://cse.csusb.edu/dick/samples/python.syntax.html#stringprefix
which lists alternate string prefixes.

Does any bodyy know if "ur" and "UR" mean the same thing?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top