MCPcopy Create free account
hub / github.com/ipython/ipython / _seq_pprinter_factory

Function _seq_pprinter_factory

IPython/lib/pretty.py:541–560  ·  view source on GitHub ↗

Factory that returns a pprint function useful for sequences. Used by the default pprint for tuples, dicts, and lists.

(start, end)

Source from the content-addressed store, hash-verified

539
540
541def _seq_pprinter_factory(start, end):
542 """
543 Factory that returns a pprint function useful for sequences. Used by
544 the default pprint for tuples, dicts, and lists.
545 """
546 def inner(obj, p, cycle):
547 if cycle:
548 return p.text(start + '...' + end)
549 step = len(start)
550 p.begin_group(step, start)
551 for idx, x in p._enumerate(obj):
552 if idx:
553 p.text(',')
554 p.breakable()
555 p.pretty(x)
556 if len(obj) == 1 and type(obj) is tuple:
557 # Special case for 1-item tuples.
558 p.text(',')
559 p.end_group(step, end)
560 return inner
561
562
563def _set_pprinter_factory(start, end):

Callers 1

pretty.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected