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

Function _default_pprint

IPython/lib/pretty.py:598–633  ·  view source on GitHub ↗

The default print function. Used if an object does not provide one and it's none of the builtin objects.

(obj, p, cycle)

Source from the content-addressed store, hash-verified

596
597
598def _default_pprint(obj, p, cycle):
599 """
600 The default print function. Used if an object does not provide one and
601 it's none of the builtin objects.
602 """
603 klass = _safe_getattr(obj, '__class__', None) or type(obj)
604 if _safe_getattr(klass, '__repr__', None) is not object.__repr__:
605 # A user-provided repr. Find newlines and replace them with p.break_()
606 _repr_pprint(obj, p, cycle)
607 return
608 p.begin_group(1, '<')
609 p.pretty(klass)
610 p.text(' at 0x%x' % id(obj))
611 if cycle:
612 p.text(' ...')
613 elif p.verbose:
614 first = True
615 for key in dir(obj):
616 if not key.startswith('_'):
617 try:
618 value = getattr(obj, key)
619 except AttributeError:
620 continue
621 if isinstance(value, types.MethodType):
622 continue
623 if not first:
624 p.text(',')
625 p.breakable()
626 p.text(key)
627 p.text('=')
628 step = len(key) + 1
629 p.indentation += step
630 p.pretty(value)
631 p.indentation -= step
632 first = False
633 p.end_group(1, '>')
634
635
636def _seq_pprinter_factory(start, end):

Callers 1

prettyMethod · 0.85

Calls 7

_safe_getattrFunction · 0.85
_repr_pprintFunction · 0.85
begin_groupMethod · 0.80
prettyMethod · 0.80
breakableMethod · 0.80
end_groupMethod · 0.80
textMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…