Python vs. Perl, which is better to learn?
Roy Smith
roy at panix.com
Wed May 1 08:08:03 EDT 2002
"Billy Ng" <kwokng at earthlink.net> wrote:
> I am also new to python. I think python will be my replacement of perl.
> However, if I need to do very heavy regular expression, I still prefer perl.
> I just don't feel comfortable with the python's re syntax.
Granted, it's a little more verbose to say:
m = re.match (...)
if m:
blah = m.group (1)
then to do
if (m/.../) {
blah = $1;
}
but not much. On the other hand, I've been burned several times by failing
to keep track of when $1 goes out of scope (or maybe "automagically gets
redefined" is a better way of putting it?). If you've got to save all the
$'s in new variables immediately after the regex, the perl version can
easily get more verbose than python, since everything is tucked away in the
match object, and stays there for as long as you need it.
More information about the Python-list
mailing list