
4 Oct
2018
4 Oct
'18
10:41 a.m.
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.