Whats up with re module vs pre

Dennis Benzinger Dennis.Benzinger at gmx.net
Thu Feb 17 18:01:46 EST 2005


pythonUser_07 wrote:
> This is a very generic observation as I don't have a lot of specifics
> with me right now.  I have noticed over the past two years that the
> python "re" module is somewhat unreliable.  

What do you mean with unreliable?
Can you show an example where re does not work as expected?

> At the suggestion of
> someone quite some time ago, I started to use the deprecated "pre"
> module. "import pre as re". All my problems went away.
> 
> So here I am two years later, writing another script and I had
> forgotten about "pre" and wallah
> 
> $ python proc.py
> Traceback (most recent call last):
>   File "proc.py", line 39, in ?
>     c = collect("nohup.out")
>   File "proc.py", line 20, in collect
>     m = p.search(cont)
> RuntimeError: maximum recursion limit exceeded
> 
> As soon as I switched "import re" to "import pre as re" my program
> worked as expected.   In the words of Jerry Sienfeld, what's up with
> that?

Try again with Python 2.4. The re module is now non-recursive
(http://www.python.org/2.4/highlights.html), so you shouldn't get any
"maximum recursion limit exceeded" errors.


Bye,
Dennis



More information about the Python-list mailing list