"re" vs "sre"?

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Sat Sep 23 08:14:27 EDT 2006


In message <ef387g$t6m$01$1 at 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"?



More information about the Python-list mailing list