What is Python?

Peter Hansen peter at engcorp.com
Tue Sep 19 05:35:34 CEST 2000


William Tanksley wrote:
> 
> On Mon, 18 Sep 2000 19:47:50 GMT, drobinow at my-deja.com wrote:
> >  tim at degree.ath.cx (Tim Hammerquist) wrote:
> >> As a matter of interest, anyone want to convert the following code to
> >> Python?
> 
> >> perl -npe 'next unless /\bjudea/i && /\bfront\b/i' /scripts/movies/brian/*
> 
> >Sure. What's it do?
> 
> It prints all of the lines in all of the indicated files which contain the
> word-start "judea" and the word "front".
> 
> Here's another way of saying that:
> 
> cat /scripts/movies/brian/* | grep "\\bjudea" | grep "\\bfront\\b"

Now that's just the thing, isn't it?  With my minimal experience (a few
self-taught hours back in the early 80s and snippets since) using Unix,
I can actually understand the shell/pipe version above to some extent. 
Sort of like I can still understand some French (learned in the same
era).

The Perl version, on the other hand, which I've thankfully not been
required actually to use, looks more like an obfuscated C competition
winner.  Sort of like German looks to my eye, even after a couple of
courses.

The Python version Alex posted, on the other hand (yes, I have three!),
not only makes it explicit what is going on, but looks rather
maintainable (even to someone with minimal exposure to Python, I'll
bet).  Continuing the spoken language analogy... Esperanto, anyone?

-- 
Peter Hansen



More information about the Python-list mailing list