Whats up with re module vs pre

P

pythonUser_07

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. 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?
 
D

Dennis Benzinger

pythonUser_07 said:
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
 
P

pythonUser_07

Like I said, I don't have a lot of specifics. This is more of an over
time experience.

I do know that any problem I had with "re" was always resolved by
"pre". Maybe they all had to do with recursion though.

Thanks for the heads up on python2.4. Now all I have to do is get our
admins to install... sigh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top