Python vs. Perl, which is better to learn?

James J. Besemer jb at cascade-sys.com
Wed May 1 18:43:09 EDT 2002


Mark McEahern wrote:

> As others have remarked, I prefer the explicitness of Python's re
> module--you have to import it to use it.

I absolutely agree.

Among other things, Python allows alternative implementations of RE, while Perl
has just 1 standard (IIRC, they may have some alternative RE packages, for
backwards compatibility or something).

Furthermore, compiled regular expressions is a natural property of Python's
implementation but I could not figure out how to do that in Perl (if it's
possible at all (I seem to recall it was somehow but could not find a
referenc)).

Let me emphasize that I did NOT at all intend to show Perl's SUPERORITY.  I
said it was too strong a word.  I just wanted to illustrate how Perl did things
and that regex is "builtin" to the language.  FWIW, I've read at least one
published comparison of Perl vs. Python and the writer ended up picking Perl by
a small margin and the greater number of turn-key features (larger set of
builtins) was what tilted the scale.

Anyway, I wrote to damn Perl, not praise it.  With a conscious effort to avoid
sarcasm, I thought the examples would speak for themselves -- in provoking a
gag reflex, if nothing else.

I certainly agree with all of Mark's comments and criticisms about the Perl
examples.  In particular, I never cared for Perl's notion of "default"
operands, as I could never keep straight what the default was in different
contexts.

Finally, it was a careless omission on my part to imply that Python regex
lacked the "{n,m}" pattern.  Thanks to all who pointed it out.

Regards

--jb

--
James J. Besemer  503-280-0838 voice
http://cascade-sys.com  503-280-0375 fax
mailto:jb at cascade-sys.com







More information about the Python-list mailing list