matching one time through a loop

Ville Vainio vvainio at tp.spt.fi
Fri May 31 08:35:45 EDT 2002


"David K. Trudgett" <dkt at registriesltd.com.au> wrote in message news:<mailman.1022806551.14232.python-list at python.org>...

> with other factors like cleanness, readability, and so on. Obviously,
> Python comes down on the cleanness/readability side, at the expense of
> programmer productivity in text processing.

I dunno about you, but I spend at least 8.4 seconds each time I think
up & type a non-trivial regular expression. Compare that to the 1.3
seconds it takes to type re.search or re.sub (and I guess it takes you
some time also to type those tildes, ='s and /'s. Hint: you do *not*
have to compile the regexp beforehand.

BTW, how does perl do re.findall()? Or re.sub using function return
values to dynamically determine the replacement? I can't remember I
ever used such features with perl.

My experience is that Python regexps are better when you go beyond
non-trivial, with clear group & matchobject semantics (and using
return values instead of in-place replacement). Or target something
apart from $_. Perl regexps were special back when others used
old-style regexps, but those times are over - python provides
perl-style regexps.

> Don't know about that. I don't personally find that a problem. If I
> had learned Python first, I might have had a different opinion,
> perhaps ;-)

I don't think it has much significance. Most people here probably
learned perl first.



More information about the Python-list mailing list