Learning Python now coming from Perl

Python Nutter pythonnutter at gmail.com
Sun Dec 7 02:54:49 CET 2008


> In article <014a96e0$0$20670$c3e8da3 at news.astraweb.com>,
>  Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:
>
> Well, as an old-time unix hacker (who learned REs long before Perl
> existed), my question to you would be, "Is there any problem which
> *shouldn't* be solved with an RE?" :-)
>
> One of the reasons REs don't get used in Python as much as in Perl is
> because strings have useful methods like startswith(), endswith(), and
> split(), and also the "in" operator.  These combine to give you easy ways
> to do many things you might otherwise do with REs.


I agree, I'm going through the new book Python for Unix and Linux
Administration now and although in general I like what they say, they
take you through the built in string functions and then introduce REs
and end the chapter leaving the reader with the impression that REs
are the better solution and I only agree with the case of the
problem/program they presented.

However I used the built ins more effectively using the indexes
returned within the string and I've built plenty of scripts that did
not need to move to REs to perform the text/file processing that I
did. This intermediate use of string built-in functions was missing
between the first string-function and RE versions of code and imho it
is not letting the readers see that string-functions are even more
powerful than the reader is lead to believe and that REs are pushed
more towards edge cases than the impression the reader seems to be
left with which is to use REs more.

At least if you push REs inform the readers where to get the a RE GUI
builder written in Python so they can build and *test* the complex and
unwieldy REs to perform anything beyond the basic pattern searches.

Cheers,
PN



More information about the Python-list mailing list