[Python-3000] doctest portability

Stefan Behnel stefan_ml at behnel.de
Sun Jun 1 08:44:35 CEST 2008


Guido van Rossum wrote:
> 2to3 lets you specify exactly which fixers to run with the -f command line flag.

Nice, one problem solved then. I assume that's also available in the library
version?

 object. I find that very inconvenient.BTW, last time I checked, options were
passed into lib2to3 as attributes of an  A dict or keyword arguments would
work much better.


> I really don't like the idea of having Py3k code with doctests written
> in a dialect of Py2k...

There's two types of doctests, one that is meant as user readable examples and
one where the doctest module is used for convenience. I agree that doctests
should use a consistent syntax, either Py2 or Py3, especially if they are
meant as documentation. But that's currently not easy to achieve in a portable
way. Py2 byte strings are the most obvious problem.

I don't think that every software package that supports Py3 will convert its
doctests to Py3 syntax, at least as long as there is no perfectly working 3to2
doctest converter that converts byte/unicode strings correctly. And even then,
it would have to be integrated with the doctest module.

Having to split your code base just because your tests don't run on a new
target platform is not an option IMHO. That would rather keep people from
supporting Py3.

Stefan



More information about the Python-3000 mailing list