@@ -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)
@@ -261,7 +264,7 @@ are converted to strings. The default implementation uses the internals of the
261
264
Example
262
265
-------
263
266
264
- To demonstrate several uses of the :func: `~pprint.pprint ` function and its parameters,
267
+ To demonstrate several uses of the :func: `~pprint.pp ` function and its parameters,
265
268
let's fetch information about a project from `PyPI <https://pypi.org >`_::
266
269
267
270
>>> import json
@@ -270,9 +273,9 @@ let's fetch information about a project from `PyPI <https://pypi.org>`_::
270
273
>>> with urlopen('https://pypi.org/pypi/sampleproject/json') as resp:
271
274
... project_info = json.load(resp)['info']
272
275
273
- In its basic form, :func: `~pprint.pprint ` shows the whole object::
276
+ In its basic form, :func: `~pprint.pp ` shows the whole object::
274
277
275
- >>> pprint.pprint (project_info)
278
+ >>> pprint.pp (project_info)
276
279
{'author': 'The Python Packaging Authority',
277
280
'author_email': '[email protected] ',
278
281
'bugtrack_url': None,
@@ -329,7 +332,7 @@ In its basic form, :func:`~pprint.pprint` shows the whole object::
329
332
The result can be limited to a certain *depth * (ellipsis is used for deeper
330
333
contents)::
331
334
332
- >>> pprint.pprint (project_info, depth=1)
335
+ >>> pprint.pp (project_info, depth=1)
333
336
{'author': 'The Python Packaging Authority',
334
337
'author_email': '[email protected] ',
335
338
'bugtrack_url': None,
@@ -375,7 +378,7 @@ contents)::
375
378
Additionally, maximum character *width * can be suggested. If a long object
376
379
cannot be split, the specified width will be exceeded::
377
380
378
- >>> pprint.pprint (project_info, depth=1, width=60)
381
+ >>> pprint.pp (project_info, depth=1, width=60)
379
382
{'author': 'The Python Packaging Authority',
380
383
'author_email': '[email protected] ',
381
384
'bugtrack_url': None,
0 commit comments