Mercurial > cpython-lru_cache-weakref
diff Lib/pprint.py @ 31085:a2f6c6a67f24 legacy-trunk
Add parameters indent, width and depth to pprint.pprint() and pprint.pformat()
and pass them along to the PrettyPrinter constructor.
| author | Walter Dörwald <walter@livinglogic.de> |
|---|---|
| date | Wed, 03 Dec 2003 20:26:05 +0000 |
| parents | e3025fe70d8b |
| children | 71a294bd7950 |
line wrap: on
line diff
--- a/Lib/pprint.py Wed Dec 03 20:15:28 2003 +0000 +++ b/Lib/pprint.py Wed Dec 03 20:26:05 2003 +0000 @@ -48,14 +48,15 @@ _type = type -def pprint(object, stream=None): +def pprint(object, stream=None, indent=1, width=80, depth=None): """Pretty-print a Python object to a stream [default is sys.sydout].""" - printer = PrettyPrinter(stream=stream) + printer = PrettyPrinter( + stream=stream, indent=indent, width=width, depth=depth) printer.pprint(object) -def pformat(object): +def pformat(object, indent=1, width=80, depth=None): """Format a Python object into a pretty-printed representation.""" - return PrettyPrinter().pformat(object) + return PrettyPrinter(indent=indent, width=width, depth=depth).pformat(object) def saferepr(object): """Version of repr() which can handle recursive data structures."""
