On 16.11.2010 22:56, 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?
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.
One of Python's main strength is it's brilliant interactive mode,
where you can easily try things out (Hint: Try ipython for an even
better interactive experience)
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> ru"Scheißt\nderBär\nim Wald?"
File "<stdin>", line 1
ru"Scheißt\nderBär\nim Wald?"
^
SyntaxError: invalid syntax
>>> ur"Scheißt\nderBär\nim Wald?"
u'Schei\xdft\\nderB\xe4r\\nim Wald?'
>>>
Looks like ur"" works fine.
--
http://mail.python.org/mailman/listinfo/python-list