Raw Unicode docstring

Robert Kern robert.kern at gmail.com
Tue Nov 16 17:26:18 EST 2010


On 11/16/10 3:56 PM, Boštjan Mejak wrote:
> 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?

I would just use a double-backslash u'\\' for each backslash that is supposed to 
be in the actual string.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list