diff options
Diffstat (limited to 'Doc/library/pprint.rst')
| -rw-r--r-- | Doc/library/pprint.rst | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/Doc/library/pprint.rst b/Doc/library/pprint.rst index 6670cf8..3e2e892 100644 --- a/Doc/library/pprint.rst +++ b/Doc/library/pprint.rst @@ -46,14 +46,14 @@ The :mod:`pprint` module defines one class: the depth of the objects being formatted. The desired output width is constrained using the *width* parameter; the default is 80 characters. If a structure cannot be formatted within the constrained width, a best effort will - be made. :: + be made. >>> import pprint >>> stuff = ['spam', 'eggs', 'lumberjack', 'knights', 'ni'] >>> stuff.insert(0, stuff[:]) >>> pp = pprint.PrettyPrinter(indent=4) >>> pp.pprint(stuff) - [ ['spam', 'eggs', 'lumberjack', 'knights', 'ni'], + [ [ 'spam', 'eggs', 'lumberjack', 'knights', 'ni'], 'spam', 'eggs', 'lumberjack', @@ -84,19 +84,18 @@ The :class:`PrettyPrinter` class supports several derivative functions: in the interactive interpreter instead of the :func:`print` function for inspecting values (you can even reassign ``print = pprint.pprint`` for use within a scope). *indent*, *width* and *depth* will be passed to the - :class:`PrettyPrinter` constructor as formatting parameters. :: + :class:`PrettyPrinter` constructor as formatting parameters. >>> import pprint >>> stuff = ['spam', 'eggs', 'lumberjack', 'knights', 'ni'] >>> stuff.insert(0, stuff) >>> pprint.pprint(stuff) - [<Recursion on list with id=869440>, - '', - '/usr/local/lib/python1.5', - '/usr/local/lib/python1.5/test', - '/usr/local/lib/python1.5/sunos5', - '/usr/local/lib/python1.5/sharedmodules', - '/usr/local/lib/python1.5/tkinter'] + [<Recursion on list with id=...>, + 'spam', + 'eggs', + 'lumberjack', + 'knights', + 'ni'] .. function:: isreadable(object) @@ -105,7 +104,7 @@ The :class:`PrettyPrinter` class supports several derivative functions: Determine if the formatted representation of *object* is "readable," or can be used to reconstruct the value using :func:`eval`. This always returns ``False`` - for recursive objects. :: + for recursive objects. >>> pprint.isreadable(stuff) False @@ -115,8 +114,8 @@ The :class:`PrettyPrinter` class supports several derivative functions: Determine if *object* requires a recursive representation. -One more support function is also defined: +One more support function is also defined: .. function:: saferepr(object) @@ -125,12 +124,8 @@ One more support function is also defined: recursive reference will be represented as ``<Recursion on typename with id=number>``. The representation is not otherwise formatted. -:: - >>> pprint.saferepr(stuff) - "[<Recursion on list with id=682968>, '', '/usr/local/lib/python1.5', '/usr/loca - l/lib/python1.5/test', '/usr/local/lib/python1.5/sunos5', '/usr/local/lib/python - 1.5/sharedmodules', '/usr/local/lib/python1.5/tkinter']" + "[<Recursion on list with id=...>, 'spam', 'eggs', 'lumberjack', 'knights', 'ni']" .. _prettyprinter-objects: |
