devguide icon indicating copy to clipboard operation
devguide copied to clipboard

Add discussion of doctesting interactive code examples.

Open terryjreedy opened this issue 1 year ago • 0 comments

There have been various discussions about doctesting interactive code examples in the python docs. The consensus has been that it is desirable that they pass. Indeed, CI currently has a (pass-not-required) Tests / Docs / Doctest. (But it seems to be setup to be excessively lenient, passing many errors that are normally caught. Intended? Bug?) There has been additional discussion about use of particular features, such as doctest directives. An example from the doc:

The [ELLIPSIS](https://docs.python.org/3/library/doctest.html#doctest.ELLIPSIS) directive
gives a nice approach for the last example:
>>> C()  # doctest: +ELLIPSIS
<C object at 0x...>

Other people may remember such discussions better. In any case, a summary of current policy should be added either in Documentation / Style Guide /Code Examples or in a new "Interactive Code Examples and Doctest" section immediately after.

terryjreedy avatar Jul 13 '23 19:07 terryjreedy