Raw Unicode docstring
tjreedy at udel.edu
Tue Nov 16 23:33:14 CET 2010
On 11/16/2010 4:56 PM, Boštjan Mejak wrote:
> 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."""
You only need (and want that) if you want '\' to be taken literally. And
even if you do, '\\' will put one '\' in the string, so raw mode is
never needed; it is only a convenience when one needs lots of literal
> 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."""
> ur"""My unicode docstring."""
> Please answer my question, although it may sound like a noobish one. Thanks.
You could look in the manual, which has been improved in this regard for
2.7.1. Or you could try both and see which gives a syntax error ;=).
That would have been faster than posting this.
Terry Jan Reedy
More information about the Python-list