Message149409
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')" |
|
Date |
User |
Action |
Args |
2011-12-13 21:24:20 | mrabarnett | set | recipients:
+ mrabarnett, rhettinger, pitrou, ezio.melotti, dwt |
2011-12-13 21:24:20 | mrabarnett | set | messageid: <1323811460.65.0.322133658866.issue13592@psf.upfronthosting.co.za> |
2011-12-13 21:24:20 | mrabarnett | link | issue13592 messages |
2011-12-13 21:24:19 | mrabarnett | create | |
|