Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
270a9411
Commit
270a9411
authored
Jan 23, 2008
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let pprint() support sets and frozensets (suggested by David Mertz).
parent
4cb196cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
2 deletions
+20
-2
Doc/library/pprint.rst
Doc/library/pprint.rst
+3
-0
Lib/pprint.py
Lib/pprint.py
+15
-2
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Doc/library/pprint.rst
View file @
270a9411
...
...
@@ -25,6 +25,9 @@ width constraint.
dictionary was sorted only if its display required more than one line, although
that wasn't documented.
.. versionchanged:: 2.6
Added support for :class:`set` and :class:`frozenset`.
The :mod:`pprint` module defines one class:
.. First the implementation class:
...
...
Lib/pprint.py
View file @
270a9411
...
...
@@ -162,11 +162,24 @@ class PrettyPrinter:
write
(
'}'
)
return
if
(
issubclass
(
typ
,
list
)
and
r
is
list
.
__repr__
)
or
\
(
issubclass
(
typ
,
tuple
)
and
r
is
tuple
.
__repr__
):
if
((
issubclass
(
typ
,
list
)
and
r
is
list
.
__repr__
)
or
(
issubclass
(
typ
,
tuple
)
and
r
is
tuple
.
__repr__
)
or
(
issubclass
(
typ
,
set
)
and
r
is
set
.
__repr__
)
or
(
issubclass
(
typ
,
frozenset
)
and
r
is
frozenset
.
__repr__
)
):
if
issubclass
(
typ
,
list
):
write
(
'['
)
endchar
=
']'
elif
issubclass
(
typ
,
set
):
write
(
'set(['
)
endchar
=
'])'
object
=
sorted
(
object
)
indent
+=
4
elif
issubclass
(
typ
,
frozenset
):
write
(
'frozenset(['
)
endchar
=
'])'
object
=
sorted
(
object
)
indent
+=
9
else
:
write
(
'('
)
endchar
=
')'
...
...
Misc/NEWS
View file @
270a9411
...
...
@@ -378,6 +378,8 @@ Core and builtins
Library
-------
- The pprint module now supports sets and frozensets.
- #1221598: add optional callbacks to ftplib.FTP'
s
storbinary
()
and
storlines
()
methods
.
(
Contributed
by
Phil
Schwartz
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment