re.compile question
Fredrik Lundh
effbot at telia.com
Tue Feb 29 12:31:52 EST 2000
Gregoire Welraeds <greg at perceval.be> wrote:
> How can I test that a re.compile has failed, Eg: If i simply forget a (
> in my regular expression
why not just compile a bad expression and
see what happens? ;-)
>>> re.compile("(")
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "C:\py152\lib\re.py", line 79, in compile
code=pcre_compile(pattern, flags, groupindex)
pcre.error: ('missing )', 1)
(to catch the exception, use try/except re.error)
</F>
More information about the Python-list
mailing list