[Python-ideas] Debugging: some problems and possible solutions
rhodri at kynesim.co.uk
Thu Oct 4 13:54:08 EDT 2018
On 04/10/18 18:41, Jonathan Fine wrote:
> 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 at python.org
> Code of Conduct: http://python.org/psf/codeofconduct/
Or write your debug output to stderr?
Rhodri James *-* Kynesim Ltd
More information about the Python-ideas