aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/pprint.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/pprint.py')
-rw-r--r--Lib/pprint.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/Lib/pprint.py b/Lib/pprint.py
index 6449868d5d8..09b4a9f41e7 100644
--- a/Lib/pprint.py
+++ b/Lib/pprint.py
@@ -159,11 +159,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('{')
+ endchar = '}'
+ object = sorted(object)
+ indent += 4
+ elif issubclass(typ, frozenset):
+ write('frozenset([')
+ endchar = '])'
+ object = sorted(object)
+ indent += 9
else:
write('(')
endchar = ')'