Python vs. Perl

Roy Smith roy at panix.com
Sat Dec 11 12:02:01 EST 2004


Michael McGarry <replytogroup at nospam.org> wrote:
> I am just starting to use Python. Does Python have all the regular 
> expression features of Perl?

I can't vouch for "all", but the Python reference manual for the "re" 
module (http://docs.python.org/lib/module-re.html) says, "This module 
provides regular expression matching operations similar to those found 
in Perl".

> Is Python missing any features available in Perl?

Are you talking specifically about regex, or about the language in 
general?  If the latter, then the answer is "Yes, and this is a Good 
Thing".  If you meant the former, then I suspect the answer is that 
anything you can do with a Perl regex you can also do with a Python 
regex.  I'm a pretty heavy regex user, and I've never found anything I 
wanted to do which I was unable to.

The biggest difference between regex support in Perl and Python is that 
Perl has regex syntax built into the core language, while Python does it 
with a module that you have to import and then call functions inside 
that module.  Which you like better is a matter of personal opinion.  
Like most Perl-Python feature comparisons, the Perl version usually ends 
up more compact, but the Python version ends up easier to understand.



More information about the Python-list mailing list