@@ -44,6 +44,17 @@ Functions
44
44
*args * and *kwargs * will be passed to :func: `~pprint.pprint ` as formatting
45
45
parameters.
46
46
47
+ >>> import pprint
48
+ >>> stuff = [' spam' , ' eggs' , ' lumberjack' , ' knights' , ' ni' ]
49
+ >>> stuff.insert(0 , stuff)
50
+ >>> pprint.pp(stuff)
51
+ [<Recursion on list with id=...>,
52
+ 'spam',
53
+ 'eggs',
54
+ 'lumberjack',
55
+ 'knights',
56
+ 'ni']
57
+
47
58
.. versionadded :: 3.8
48
59
49
60
@@ -61,16 +72,8 @@ Functions
61
72
:class: `PrettyPrinter ` constructor and their meanings are as
62
73
described in its documentation below.
63
74
64
- >>> import pprint
65
- >>> stuff = [' spam' , ' eggs' , ' lumberjack' , ' knights' , ' ni' ]
66
- >>> stuff.insert(0 , stuff)
67
- >>> pprint.pprint(stuff)
68
- [<Recursion on list with id=...>,
69
- 'spam',
70
- 'eggs',
71
- 'lumberjack',
72
- 'knights',
73
- 'ni']
75
+ Note that *sort_dicts * is ``True `` by default and you might want to use
76
+ :func: `~pprint.pp ` instead where it is ``False `` by default.
74
77
75
78
.. function :: pformat(object, indent=1, width=80, depth=None, *, \
76
79
compact=False, sort_dicts=True, underscore_numbers=False)
@@ -258,7 +261,7 @@ are converted to strings. The default implementation uses the internals of the
258
261
Example
259
262
-------
260
263
261
- To demonstrate several uses of the :func: `~pprint.pprint ` function and its parameters,
264
+ To demonstrate several uses of the :func: `~pprint.pp ` function and its parameters,
262
265
let's fetch information about a project from `PyPI <https://pypi.org >`_::
263
266
264
267
>>> import json
@@ -267,9 +270,9 @@ let's fetch information about a project from `PyPI <https://pypi.org>`_::
267
270
>>> with urlopen('https://pypi.org/pypi/sampleproject/json') as resp:
268
271
... project_info = json.load(resp)['info']
269
272
270
- In its basic form, :func: `~pprint.pprint ` shows the whole object::
273
+ In its basic form, :func: `~pprint.pp ` shows the whole object::
271
274
272
- >>> pprint.pprint (project_info)
275
+ >>> pprint.pp (project_info)
273
276
{'author': 'The Python Packaging Authority',
274
277
'author_email': '[email protected] ',
275
278
'bugtrack_url': None,
@@ -326,7 +329,7 @@ In its basic form, :func:`~pprint.pprint` shows the whole object::
326
329
The result can be limited to a certain *depth * (ellipsis is used for deeper
327
330
contents)::
328
331
329
- >>> pprint.pprint (project_info, depth=1)
332
+ >>> pprint.pp (project_info, depth=1)
330
333
{'author': 'The Python Packaging Authority',
331
334
'author_email': '[email protected] ',
332
335
'bugtrack_url': None,
@@ -372,7 +375,7 @@ contents)::
372
375
Additionally, maximum character *width * can be suggested. If a long object
373
376
cannot be split, the specified width will be exceeded::
374
377
375
- >>> pprint.pprint (project_info, depth=1, width=60)
378
+ >>> pprint.pp (project_info, depth=1, width=60)
376
379
{'author': 'The Python Packaging Authority',
377
380
'author_email': '[email protected] ',
378
381
'bugtrack_url': None,
0 commit comments