@@ -46,6 +46,8 @@ The :mod:`pprint` module defines one class:
4646
4747 *stream * (default ``sys.stdout ``) is a :term: `file-like object ` to
4848 which the output will be written by calling its :meth: `write ` method.
49+ If both *stream * and ``sys.stdout `` are ``None ``, then
50+ :meth: `~PrettyPrinter.pprint ` silently returns.
4951
5052 Other values configure the manner in which nesting of complex data
5153 structures is displayed.
@@ -84,6 +86,9 @@ The :mod:`pprint` module defines one class:
8486 .. versionchanged :: 3.10
8587 Added the *underscore_numbers * parameter.
8688
89+ .. versionchanged :: 3.11
90+ No longer attempts to write to ``sys.stdout `` if it is None.
91+
8792 >>> import pprint
8893 >>> stuff = [' spam' , ' eggs' , ' lumberjack' , ' knights' , ' ni' ]
8994 >>> stuff.insert(0 , stuff[:])
@@ -107,24 +112,13 @@ The :mod:`pprint` module defines one class:
107112 >>> pp.pprint(tup)
108113 ('spam', ('eggs', ('lumberjack', ('knights', ('ni', ('dead', (...)))))))
109114
110-
111- The :mod: `pprint ` module also provides several shortcut functions:
112-
113115.. function :: pformat(object, indent=1, width=80, depth=None, *, \
114116 compact=False, sort_dicts=True, underscore_numbers=False)
115117
116118 Return the formatted representation of *object * as a string. *indent *,
117- *width *, *depth *, *compact *, *sort_dicts * and *underscore_numbers * will be passed to the
118- :class: `PrettyPrinter ` constructor as formatting parameters.
119-
120- .. versionchanged :: 3.4
121- Added the *compact * parameter.
122-
123- .. versionchanged :: 3.8
124- Added the *sort_dicts * parameter.
125-
126- .. versionchanged :: 3.10
127- Added the *underscore_numbers * parameter.
119+ *width *, *depth *, *compact *, *sort_dicts * and *underscore_numbers * are
120+ passed to the :class: `PrettyPrinter ` constructor as formatting parameters
121+ and their meanings are as described in its documentation above.
128122
129123
130124.. function :: pp(object, *args, sort_dicts=False, **kwargs)
@@ -142,20 +136,15 @@ The :mod:`pprint` module also provides several shortcut functions:
142136 compact=False, sort_dicts=True, underscore_numbers=False)
143137
144138 Prints the formatted representation of *object * on *stream *, followed by a
145- newline. If *stream * is ``None ``, ``sys.stdout `` is used. This may be used
139+ newline. If *stream * is ``None ``, ``sys.stdout `` is used. This may be used
146140 in the interactive interpreter instead of the :func: `print ` function for
147141 inspecting values (you can even reassign ``print = pprint.pprint `` for use
148- within a scope). *indent *, *width *, *depth *, *compact *, *sort_dicts * and *underscore_numbers * will
149- be passed to the :class: `PrettyPrinter ` constructor as formatting parameters.
150-
151- .. versionchanged :: 3.4
152- Added the *compact * parameter.
153-
154- .. versionchanged :: 3.8
155- Added the *sort_dicts * parameter.
142+ within a scope).
156143
157- .. versionchanged :: 3.10
158- Added the *underscore_numbers * parameter.
144+ The configuration parameters *stream *, *indent *, *width *, *depth *,
145+ *compact *, *sort_dicts * and *underscore_numbers * are passed to the
146+ :class: `PrettyPrinter ` constructor and their meanings are as
147+ described in its documentation above.
159148
160149 >>> import pprint
161150 >>> stuff = [' spam' , ' eggs' , ' lumberjack' , ' knights' , ' ni' ]
@@ -168,7 +157,6 @@ The :mod:`pprint` module also provides several shortcut functions:
168157 'knights',
169158 'ni']
170159
171-
172160.. function :: isreadable(object)
173161
174162 .. index :: builtin: eval
0 commit comments