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')" |