Make pprint the default print?

What is the reason that pprint is not made the default print?

  1. It is written in Python. That makes it harder (but not impossible) to make it a builtin.
  2. Although pprint does go back a long time, to Python 1.5 or older, it is not as old as the builtin print.
  3. It is heavier-weight than the builtin print. It requires a moderately large class, regexes, and much more to work. Making it the default will slow down Python startup for people who don’t care about pretty-printing, or do their own.
  4. The output format is different, so changing the default will break doctests that use the original print.
  5. Changing the builtin print to pprint will break backwards compatibility: the signatures of the two functions are completely different:
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
pprint(object, stream=None, indent=1, width=80, depth=None, *, compact=False)

It is easy enough to import pprint. Not everything needs to be a builtin. But if you want to make it even easier, create a PYSTARTUP file and put from pprint import pprint in it.

5 Likes