Hi, Nick Coghlan wrote: > Doctest just uses 'exec' under the covers though - the only way for it > to run code using non-native syntax would be for it to be able to invoke > a non-native parser and then run the resulting AST directly, or for it > to invoke 2to3 on the docstring.
I think it should do the latter. > Sphinx (the tool used to build the Python docs) gets around this by > allowing code to be included in the doc source that is used when running > the doctests, but hidden when generating output for human consumption > (HTML, PDF, etc) That's what I do, too, in a couple of places, e.g. to import StringIO/BytesIO or to make unicode() available. But having to copy syntax work-around code into each source file that has doctests is the wrong trade-off, IMHO. This should be an external option passed to the doctest run. Stefan _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com