[Tutor] sneaky re.compile --is this a bug??

Albert-Jan Roskam fomcl at yahoo.com
Thu Aug 16 12:07:58 CEST 2012


To add to this, in python 2.6.5 trying to do this raises an error:

>
>Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
>[GCC 4.4.3] on linux2
>Type "help", "copyright", "credits" or "license" for more information.
>>>> import re
>>>> comp = re.compile('a')
>>>> re.match(comp, 'A', re.I)
>Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "/usr/lib/python2.6/re.py", line 137, in match
>    return _compile(pattern, flags).match(string)
>  File "/usr/lib/python2.6/re.py", line 238, in _compile
>    raise ValueError('Cannot process flags argument with a compiled pattern')
>ValueError: Cannot process flags argument with a compiled pattern
>>>> 
>
>Walter, Hugo,
>
>THANKS for your replies. I am getting my sanity back again. ;-) This is another reason to stay up-to-date with software versions. I wish my company upgraded to 2.7.highest and ditched all the older versions. In the future, I'll also use re.compile in the way Walter describes.
>
>Albert-Jan
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120816/715dd400/attachment.html>


More information about the Tutor mailing list