MCPcopy Index your code
hub / github.com/ipython/ipython / _set_pprinter_factory

Function _set_pprinter_factory

IPython/lib/pretty.py:658–682  ·  view source on GitHub ↗

Factory that returns a pprint function useful for sets and frozensets.

(start, end)

Source from the content-addressed store, hash-verified

656
657
658def _set_pprinter_factory(start, end):
659 """
660 Factory that returns a pprint function useful for sets and frozensets.
661 """
662 def inner(obj, p, cycle):
663 if cycle:
664 return p.text(start + '...' + end)
665 if len(obj) == 0:
666 # Special case.
667 p.text(type(obj).__name__ + '()')
668 else:
669 step = len(start)
670 p.begin_group(step, start)
671 # Like dictionary keys, we will try to sort the items if there aren't too many
672 if not (p.max_seq_length and len(obj) >= p.max_seq_length):
673 items = _sorted_for_pprint(obj)
674 else:
675 items = obj
676 for idx, x in p._enumerate(items):
677 if idx:
678 p.text(',')
679 p.breakable()
680 p.pretty(x)
681 p.end_group(step, end)
682 return inner
683
684
685def _dict_pprinter_factory(start, end):

Callers 1

pretty.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…