doctest bug?

Heiko Wundram heikowu at ceosg.de
Mon Jul 19 13:37:45 EDT 2004


Am Montag, 19. Juli 2004 18:24 schrieb Edward K. Ream:
> Hi,
>
> I am trying to run the following docstring using docutils.DocTestSuite:
>
> """
>
> >>> s = "a\n \t\n\t\t \t\nb"
>
> etc...
> """

Check out what

print """I am here.\nAnd here again."""

prints out. Normal escaping rules apply to triple quotes, so what you want is 
actually:

print """I am here.\\nAnd here again."""

Now, if you replace \n and \t in your example by \\n and \\t, doctest won't 
complain, and a pydoc <module> will also display the strings correctly (and 
also run).

HTH!

Heiko.



More information about the Python-list mailing list