"re" vs "sre"?

  • Thread starter Lawrence D'Oliveiro
  • Start date
L

Lawrence D'Oliveiro

I learned about Python regular expressions from the Web documentation
<http://docs.python.org/lib/lib.html>. This describes a module named "re".
Then I saw some code written by a colleague, and he was using a module
named "sre". I checked my Python 2.4.3 installation, and sure enough, I
have a module named "sre" as well as "re". Curious, I fired up an
interactive Python session, and looked to see what the docstrings were for
these modules. And for the "re" module, the help says:

re - Minimal "re" compatibility wrapper. See "sre" for documentation.

and "sre" seems to have the more complete set of docstrings.

So which one should we be using?
 
P

Peter Otten

Lawrence said:
I learned about Python regular expressions from the Web documentation
<http://docs.python.org/lib/lib.html>. This describes a module named "re".
Then I saw some code written by a colleague, and he was using a module
named "sre". I checked my Python 2.4.3 installation, and sure enough, I
have a module named "sre" as well as "re". Curious, I fired up an
interactive Python session, and looked to see what the docstrings were for
these modules. And for the "re" module, the help says:

re - Minimal "re" compatibility wrapper. See "sre" for documentation.

and "sre" seems to have the more complete set of docstrings.

So which one should we be using?

Here's what Python 2.5 has to say on the matter:__main__:1: DeprecationWarning: The sre module is deprecated, please import
re.

Peter
 
L

Lawrence D'Oliveiro

Here's what Python 2.5 has to say on the matter:
__main__:1: DeprecationWarning: The sre module is deprecated, please
import re.

That's good. Does "help(re)" still say it's a "compatibility wrapper"?
 

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
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top