[Python-ideas] pprint in python 3000

Adam Atlas adam at atlas.st
Sat Aug 11 02:14:28 CEST 2007

Perhaps `repr` instead could grow a `pretty` parameter, default  
False; if true, it could also take the `depth`, `indent`, and `width`  
parameters that `pformat` now takes.

It would act basically like `pformat` in that case. Normally it would  
do its best to pretty-format known data types, using __repr__  
otherwise, but perhaps objects could also override a __prettyrepr__  
method, always taking (object, indent, width, depth), and returning a  
pretty-formated string. This function could pass those parameters  
along recursively to repr(x, pretty=True, ...) again if it has child  
objects it needs to represent.

More information about the Python-ideas mailing list