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

Function _re_pattern_pprint

IPython/lib/pretty.py:626–648  ·  view source on GitHub ↗

The pprint function for regular expression patterns.

(obj, p, cycle)

Source from the content-addressed store, hash-verified

624
625
626def _re_pattern_pprint(obj, p, cycle):
627 """The pprint function for regular expression patterns."""
628 p.text('re.compile(')
629 pattern = repr(obj.pattern)
630 if pattern[:1] in 'uU':
631 pattern = pattern[1:]
632 prefix = 'ur'
633 else:
634 prefix = 'r'
635 pattern = prefix + pattern.replace('\\\\', '\\')
636 p.text(pattern)
637 if obj.flags:
638 p.text(',')
639 p.breakable()
640 done_one = False
641 for flag in ('TEMPLATE', 'IGNORECASE', 'LOCALE', 'MULTILINE', 'DOTALL',
642 'UNICODE', 'VERBOSE', 'DEBUG'):
643 if obj.flags & getattr(re, flag):
644 if done_one:
645 p.text('|')
646 p.text('re.' + flag)
647 done_one = True
648 p.text(')')
649
650
651def _types_simplenamespace_pprint(obj, p, cycle):

Callers

nothing calls this directly

Calls 2

breakableMethod · 0.80
textMethod · 0.45

Tested by

no test coverage detected