What is Python?

William Tanksley wtanksle at dolphin.openprojects.net
Mon Sep 18 23:49:03 CEST 2000

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"

The direct translation is reasonably obvious (using the fileinput, glob,
and re modules).  My laziness is currently stopping me from finding a
non-re solution, but a truly pythonic solution wouldn't have to use re.

-William "Billy" Tanksley

More information about the Python-list mailing list