The default print function. Used if an object does not provide one and it's none of the builtin objects.
(obj, p, cycle)
| 501 | |
| 502 | |
| 503 | def _default_pprint(obj, p, cycle): |
| 504 | """ |
| 505 | The default print function. Used if an object does not provide one and |
| 506 | it's none of the builtin objects. |
| 507 | """ |
| 508 | klass = _safe_getattr(obj, '__class__', None) or type(obj) |
| 509 | if _safe_getattr(klass, '__repr__', None) is not object.__repr__: |
| 510 | # A user-provided repr. Find newlines and replace them with p.break_() |
| 511 | _repr_pprint(obj, p, cycle) |
| 512 | return |
| 513 | p.begin_group(1, '<') |
| 514 | p.pretty(klass) |
| 515 | p.text(' at 0x%x' % id(obj)) |
| 516 | if cycle: |
| 517 | p.text(' ...') |
| 518 | elif p.verbose: |
| 519 | first = True |
| 520 | for key in dir(obj): |
| 521 | if not key.startswith('_'): |
| 522 | try: |
| 523 | value = getattr(obj, key) |
| 524 | except AttributeError: |
| 525 | continue |
| 526 | if isinstance(value, types.MethodType): |
| 527 | continue |
| 528 | if not first: |
| 529 | p.text(',') |
| 530 | p.breakable() |
| 531 | p.text(key) |
| 532 | p.text('=') |
| 533 | step = len(key) + 1 |
| 534 | p.indentation += step |
| 535 | p.pretty(value) |
| 536 | p.indentation -= step |
| 537 | first = False |
| 538 | p.end_group(1, '>') |
| 539 | |
| 540 | |
| 541 | def _seq_pprinter_factory(start, end): |
no test coverage detected