On 04/10/18 18:41, Jonathan Fine wrote:
TITLE:
PROBLEM: Debug print() statements cause doctests to fail
Adding debug print(...) statements to code can cause doctests to fail.
This is because both use sys.stdout as the output stream.
POSSIBLE SOLUTION:
Provide and use a special stream for debug output. In other words,
something like
import sys
sys.stddebug = sys.stderr
debug = lambda *argv, **kwargs: print(*argv, file=sys.stddebug, flush=True,
**kwargs)
Note: Need to use current value of sys.stddebug, so can't use functools.partial.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
Or write your debug output to stderr?
--
Rhodri James *-* Kynesim Ltd
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/