On 07/16/2010 07:26 AM, [email protected] wrote:
> Thomas,
>
>> Recall that doctest doesn't parse the code, it extracts the docstrings. And
>> docstrings are just strings, and are parsed like strings.
>
> I understand what you're saying, but I'm struggling with how to
> represent the following strings in doctest code and doctest results. No
> matter what combination of backslashes or raw strings I use, I am unable
> to find a way to code the following.
>
>>>> encode( '", \, \t, \n' )
> '\", \\, \\t, \\n'
Does either of these docstrings work:
def encode(s):
"""description
>>> encode( '", \\, \\t, \\n' )
'\\", \\\\, \\\\t, \\\\n'
"""
...
def encode(s):
r"""description
>>> encode( '", \, \t, \n' )
'\", \\, \\t, \\n'
"""
...
--
http://mail.python.org/mailman/listinfo/python-list