I can't believe it took me years to figure this out, but you can very easily set
function as the default implementation to use when calling
print() during the
invocation of a shell or when running a program under the python interpreter.
The trick involves overriding the default for
and pointing it to
import sys import pprint sys.displayhook = pprint.pprint
displayhook is set, any invocation of
print() within the same
interpreter context will defer the output formatting to
If you'd like to have that as your default without having to override
sys.displayhook in all your scripts and applications, you can create a
module somewhere on your
$PYTHONPATH that will be picked up when the python
interpreter start up.