473,387 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

"re" vs "sre"?

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?
Sep 23 '06 #1
2 3997
Lawrence D'Oliveiro wrote:
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:
>>import sre
__main__:1: DeprecationWarning: The sre module is deprecated, please import
re.

Peter
Sep 23 '06 #2
In message <ef*************@news.t-online.com>, Peter Otten wrote:
Lawrence D'Oliveiro wrote:
>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:
>>>import sre
__main__:1: DeprecationWarning: The sre module is deprecated, please
import re.
That's good. Does "help(re)" still say it's a "compatibility wrapper"?
Sep 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Luc Saffre | last post by:
Hello, I had a strange problem when freezing (using either py2exe or McMillan installer) a script that imports reportlab (which imports PIL (which imports FixTk))). - Python 2.3.3c (also with...
10
by: Berthold Hoellmann | last post by:
Hello, When I use ./configure --with-thread --with-fpectl --with-signal-module \ --with-pymalloc --enable-shared --with-cxx=g++ make test on 2.3.3 I get
33
by: Steven Bethard | last post by:
I feel like this has probably been answered before, but I couldn't find something quite like it in the archives. Feel free to point me somewhere if you know where this has already been answered. ...
6
by: Xah Lee | last post by:
how to represent the unicode "em space" in regex? e.g. i want do something like this: fracture=re.split(r'\342371*\|\342371*',myline,re.U) Xah xah@xahlee.org ∑ http://xahlee.org/
28
by: robert | last post by:
In very rare cases a program crashes (hard to reproduce) : * several threads work on an object tree with dict's etc. in it. Items are added, deleted, iteration over .keys() ... ). The threads are...
7
by: John Nagle | last post by:
How do I suppress "DeprecationWarning: Old style callback, use cb_func(ok, store) instead". A library is triggering this message, the library is being fixed, but I need to make the message...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.