Is it bug or feature in sre?

Roman Suzi rnd at onego.ru
Mon Jan 5 04:08:33 EST 2004


I've accidentally tried on of my programs written for Python 1.5
and encountered this:

Python 2.3.1 (#1, Sep 25 2003, 10:15:04)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
......
>>> re.compile("(?P<gr>[A-Z]*)?")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python2.3/sre.py", line 179, in compile
    return _compile(pattern, flags)
  File "/usr/local/lib/python2.3/sre.py", line 229, in _compile
    raise error, v # invalid expression
sre_constants.error: nothing to repeat

I wonder why I can't do this? I guess it's of terrible style, but
is this behaviour intentional or not?
Probably it is good idea to mention this in Python update path
documents. Otherwise some old programs will mysteriously fail.


Sincerely yours, Roman A.Suzi
-- 
 - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru -





More information about the Python-list mailing list