doctests working both in Python 2.X and Python 3.X

Shashwat Anand anand.shashwat at gmail.com
Sun Apr 11 10:58:49 CEST 2010


On Sun, Apr 11, 2010 at 1:59 PM, Michele Simionato <
michele.simionato at gmail.com> wrote:

> I do not want to write two documentations for a module working both in
> Python 2.X and Python 3.X.
>

There are modules which work in both 2.x and 3.x but still behave
differently. How will you handle those ?
IMHO the way as it is is correct


> To avoid that, I would need the ability to interpret doctests
> according to the used Python version.
>
> I mean something like that:
>
> """
> Documentation of the module <mymodule>
> -----------------------------------------------------------------
>
> If you are using Python 2.X you can check that
>
>  >>> <2.X code> # doctest: <some directive for 2.X>
>  <2.X output>
>
> whereas if you are using Python 2.X you can check that
>
>  >>> <3.X code> # doctest: <some directive for 3.X>
>  <3.X output>
>
> Is something like that possible? If not, what are the options?
> 2to3 theoretically can converts the doctests, but in practice I have
> seen that the doctests for my decorator module needs some manual
> tweaking.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100411/659178ab/attachment.html>


More information about the Python-list mailing list