Matthew Barnett <pyt...@mrabarnett.plus.com> added the comment: Actually, one possibility that occurs to me is to provide the flags within the pattern. The .pattern attribute gives the original pattern, but repr could give the flags in-line at the start of the pattern:
>>> # Assuming Python 3. >>> r = re.compile("a", re.I) >>> r.flags 34 >>> r.pattern 'a' >>> repr(r) "<_sre.SRE_Pattern '(?i)a'>" I'm not sure how to make it eval-able, unless you mean something more like: >>> repr(r) "re.Regex('(?i)a')" where re.Regex == re.compile, which would be more meaningful than: >>> repr(r) "re.compile('(?i)a')" ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13592> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com