@@ -36,7 +36,7 @@ The :mod:`pprint` module defines one class:
36
36
.. index :: single: ...; placeholder
37
37
38
38
.. class :: PrettyPrinter(indent=1, width=80, depth=None, stream=None, *, \
39
- compact=False, sort_dicts=True)
39
+ compact=False, sort_dicts=True, underscore_numbers=False )
40
40
41
41
Construct a :class: `PrettyPrinter ` instance. This constructor understands
42
42
several keyword parameters. An output stream may be set using the *stream *
@@ -55,14 +55,19 @@ The :mod:`pprint` module defines one class:
55
55
will be formatted on a separate line. If *compact * is true, as many items
56
56
as will fit within the *width * will be formatted on each output line. If
57
57
*sort_dicts * is true (the default), dictionaries will be formatted with their
58
- keys sorted, otherwise they will display in insertion order.
58
+ keys sorted, otherwise they will display in insertion order. If
59
+ *underscore_numbers * is true, integers will be formatted with
60
+ ```_` `` character for a thousands separator, otherwise underscores are not
61
+ displayed (the default).
59
62
60
63
.. versionchanged :: 3.4
61
64
Added the *compact * parameter.
62
65
63
66
.. versionchanged :: 3.8
64
67
Added the *sort_dicts * parameter.
65
68
69
+ .. versionchanged :: 3.10
70
+ Added the *underscore_numbers * parameter.
66
71
67
72
>>> import pprint
68
73
>>> stuff = [' spam' , ' eggs' , ' lumberjack' , ' knights' , ' ni' ]
@@ -91,10 +96,10 @@ The :mod:`pprint` module defines one class:
91
96
The :mod: `pprint ` module also provides several shortcut functions:
92
97
93
98
.. function :: pformat(object, indent=1, width=80, depth=None, *, \
94
- compact=False, sort_dicts=True)
99
+ compact=False, sort_dicts=True, underscore_numbers=False )
95
100
96
101
Return the formatted representation of *object * as a string. *indent *,
97
- *width *, *depth *, *compact * and *sort_dicts * will be passed to the
102
+ *width *, *depth *, *compact *, * sort_dicts * and *underscore_numbers * will be passed to the
98
103
:class: `PrettyPrinter ` constructor as formatting parameters.
99
104
100
105
.. versionchanged :: 3.4
@@ -103,6 +108,9 @@ The :mod:`pprint` module also provides several shortcut functions:
103
108
.. versionchanged :: 3.8
104
109
Added the *sort_dicts * parameter.
105
110
111
+ .. versionchanged :: 3.10
112
+ Added the *underscore_numbers * parameter.
113
+
106
114
107
115
.. function :: pp(object, *args, sort_dicts=False, **kwargs)
108
116
@@ -116,13 +124,13 @@ The :mod:`pprint` module also provides several shortcut functions:
116
124
117
125
118
126
.. function :: pprint(object, stream=None, indent=1, width=80, depth=None, *, \
119
- compact=False, sort_dicts=True)
127
+ compact=False, sort_dicts=True, underscore_numbers=False )
120
128
121
129
Prints the formatted representation of *object * on *stream *, followed by a
122
130
newline. If *stream * is ``None ``, ``sys.stdout `` is used. This may be used
123
131
in the interactive interpreter instead of the :func: `print ` function for
124
132
inspecting values (you can even reassign ``print = pprint.pprint `` for use
125
- within a scope). *indent *, *width *, *depth *, *compact * and *sort_dicts * will
133
+ within a scope). *indent *, *width *, *depth *, *compact *, * sort_dicts * and *underscore_numbers * will
126
134
be passed to the :class: `PrettyPrinter ` constructor as formatting parameters.
127
135
128
136
.. versionchanged :: 3.4
@@ -131,6 +139,9 @@ The :mod:`pprint` module also provides several shortcut functions:
131
139
.. versionchanged :: 3.8
132
140
Added the *sort_dicts * parameter.
133
141
142
+ .. versionchanged :: 3.10
143
+ Added the *underscore_numbers * parameter.
144
+
134
145
>>> import pprint
135
146
>>> stuff = [' spam' , ' eggs' , ' lumberjack' , ' knights' , ' ni' ]
136
147
>>> stuff.insert(0 , stuff)
0 commit comments