re.compile question

Gregoire Welraeds greg at perceval.be
Tue Feb 29 12:43:51 EST 2000


In reply to the message of Gordon McMillan sent on Feb 29 (see below) :

Ok but what if I run re.compile in a CGI script and since it always return
an object. 
can I do 
>>> import re
>>> try:
...	x = re.compile("(")
... except:
...	[generate a beautifull error page]

?


--
Life is not fair
But the root password helps
--

Gregoire Welraeds
greg at perceval.be
Perceval Development team
-------------------------------------------------------------------------------
Perceval Technologies sa/nv	Tel: +32-2-6409194		
Rue Tenbosch, 9			Fax: +32-2-6403154		
B-1000 Brussels			general information:   info at perceval.net
BELGIUM				technical information: helpdesk at perceval.net
URL: http://www.perceval.be/
-------------------------------------------------------------------------------

On Tue, 29 Feb 2000, Gordon McMillan wrote:

> Date: Tue, 29 Feb 2000 12:31:05 -0500
> From: Gordon McMillan <gmcm at hypernet.com>
> To: Gregoire Welraeds <greg at perceval.be>, python-list at python.org
> Subject: Re: re.compile question
> 
> Gregoire Welraeds writes:
> > 
> > Yes it's me again ;)
> > How can I test that a re.compile has failed, Eg:  If i simply forget a (
> > in my regular expression
> > 
> > --
> > Life is not fair
> > But the root password helps
> 
> The interpreter does, too.
> 
> >>> import re
> >>> x = re.compile("(")
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
>   File "D:\Programs\Python\Lib\re.py", line 79, in compile
>     code=pcre_compile(pattern, flags, groupindex)
> pcre.error: ('missing )', 1)
> >>>
> 
> - Gordon
> 
> 






More information about the Python-list mailing list