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

Method _format_namespace_items

Lib/pprint.py:556–580  ·  view source on GitHub ↗
(self, items, stream, indent, allowance, context, level)

Source from the content-addressed store, hash-verified

554 write(',')
555
556 def _format_namespace_items(self, items, stream, indent, allowance, context, level):
557 write = stream.write
558 delimnl = ',\n' + ' ' * indent
559 last_index = len(items) - 1
560 for i, (key, ent) in enumerate(items):
561 last = i == last_index
562 write(key)
563 write('=')
564 if id(ent) in context:
565 # Special-case representation of recursion to match standard
566 # recursive dataclass repr.
567 write("...")
568 else:
569 self._format(
570 ent,
571 stream,
572 self._child_indent(indent, len(key) + 1),
573 allowance if last else 1,
574 context,
575 level,
576 )
577 if not last:
578 write(delimnl)
579 elif self._expand:
580 write(',')
581
582 def _format_items(self, items, stream, indent, allowance, context, level):
583 write = stream.write

Callers 2

_pprint_dataclassMethod · 0.95

Calls 5

_formatMethod · 0.95
_child_indentMethod · 0.95
enumerateFunction · 0.85
idFunction · 0.85
writeFunction · 0.70

Tested by

no test coverage detected