Author mrabarnett
Recipients dwt, ezio.melotti, mrabarnett, pitrou, rhettinger
Date 2011-12-13.21:24:19
SpamBayes Score 0.000325372
Marked as misclassified No
Message-id <1323811460.65.0.322133658866.issue13592@psf.upfronthosting.co.za>
In-reply-to
Content
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')"
History
Date User Action Args
2011-12-13 21:24:20mrabarnettsetrecipients: + mrabarnett, rhettinger, pitrou, ezio.melotti, dwt
2011-12-13 21:24:20mrabarnettsetmessageid: <1323811460.65.0.322133658866.issue13592@psf.upfronthosting.co.za>
2011-12-13 21:24:20mrabarnettlinkissue13592 messages
2011-12-13 21:24:19mrabarnettcreate