[Python-ideas] Debugging: some problems and possible solutions
jfine2358 at gmail.com
Thu Oct 4 13:41:22 EDT 2018
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.
Provide and use a special stream for debug output. In other words,
>>> 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.
More information about the Python-ideas