MCPcopy Index your code
hub / github.com/python/cpython / _pprint_dict_view

Method _pprint_dict_view

Lib/pprint.py:318–338  ·  view source on GitHub ↗

Pretty print dict views (keys, values, items).

(self, object, stream, indent, allowance, context, level)

Source from the content-addressed store, hash-verified

316 _dispatch[_collections.OrderedDict.__repr__] = _pprint_ordered_dict
317
318 def _pprint_dict_view(self, object, stream, indent, allowance, context, level):
319 """Pretty print dict views (keys, values, items)."""
320 if isinstance(object, self._dict_items_view):
321 key = _safe_tuple
322 else:
323 key = _safe_key
324
325 write = stream.write
326 write(
327 self._format_block_start(object.__class__.__name__ + "([", indent)
328 )
329
330 if len(object):
331 if self._sort_dicts:
332 entries = sorted(object, key=key)
333 else:
334 entries = object
335 self._format_items(
336 entries, stream, indent, allowance + 2, context, level
337 )
338 write(self._format_block_end("])", indent))
339
340 def _pprint_mapping_abc_view(self, object, stream, indent, allowance, context, level):
341 """Pretty print mapping views from collections.abc."""

Callers

nothing calls this directly

Calls 4

_format_block_startMethod · 0.95
_format_itemsMethod · 0.95
_format_block_endMethod · 0.95
writeFunction · 0.70

Tested by

no test coverage detected