[Python-ideas] doctest

Guido van Rossum guido at python.org
Fri Mar 2 19:14:41 CET 2012

On Fri, Mar 2, 2012 at 9:59 AM, Devin Jeanpierre <jeanpierreda at gmail.com> wrote:
> On Fri, Mar 2, 2012 at 12:30 PM, Guido van Rossum <guido at python.org> wrote:
>> Devin,
>> You need to start writing real code rather than continue to tell us
>> that the problems are minor and easily fixable, and the solutions are
>> uncontroversial. To those who have tried and thought about it, the
>> problems are *not* easy to solve , except for some superficial edge
>> cases that you and other critics of doctest keep focusing on.
> I already did write real code. In the context of this discussion, I
> implemented a +LITERAL_EVAL flag.
> Was there something else I was supposed to write, other than the
> solution I advocated? ;)
> https://bitbucket.org/devin.jeanpierre/doctest2/src/e084a682ccbc/doctest2/constants.py#cl-122

It's not a solution. It's a hack that only works in the simplest cases
-- it requires the output to look like a Python expression (that can
be evaluated in a limited environment). What if the output were
something like

<Future for 'foo' returning {1: 'blah', 2: 'booh'}>

??? There's a dict in there but the whole thing is not parseable.

>> And please don't propose that we change the behavior of dict or other
>> data types itself, or add new APIs to objects just for the purpose of
>> "fixing" doctest's issues.
> I would never dream of it. That's pretty obscene.

Good. I wasn't sure what you meant when you used the phrase "fix dict"
-- I presume that was shorthand for "fix the problem that doctest has
with dict".

--Guido van Rossum (python.org/~guido)

More information about the Python-ideas mailing list