Skip to content

Commit 3a07c46

Browse files
committed
frozendict
1 parent d231cdb commit 3a07c46

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Lib/pprint.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,14 @@ def _pprint_dataclass(self, object, stream, indent, allowance, context, level):
220220

221221
def _pprint_dict(self, object, stream, indent, allowance, context, level):
222222
write = stream.write
223-
write('{')
223+
typ = object.__class__
224+
if typ is dict:
225+
write('{')
226+
end = '}'
227+
else:
228+
stream.write(typ.__name__ + '({')
229+
end = '})'
230+
indent += len(typ.__name__) + 1
224231
if self._indent_per_level > 1:
225232
write((self._indent_per_level - 1) * ' ')
226233
length = len(object)
@@ -231,9 +238,10 @@ def _pprint_dict(self, object, stream, indent, allowance, context, level):
231238
items = object.items()
232239
self._format_dict_items(items, stream, indent, allowance + 1,
233240
context, level)
234-
write('}')
241+
write(end)
235242

236243
_dispatch[dict.__repr__] = _pprint_dict
244+
_dispatch[frozendict.__repr__] = _pprint_dict
237245

238246
def _pprint_ordered_dict(self, object, stream, indent, allowance, context, level):
239247
if not len(object):

0 commit comments

Comments
 (0)