(slightly OT): Python and linux - very cool

Mart van de Wege mvdwege.usenet at drebbelstraat20.dyndns.org
Thu Aug 8 18:29:37 CEST 2002

On Thu, 08 Aug 2002 07:06:01 +0200, Emile van Sebille wrote:

> Mart van de Wege:
> [snip VM questions]
>> Constructs like the 'while (<FILEHANDLE>)' loop, which takes a  line
> from a
>> file  until EOF (meanwhile assigning it to the default variable) make
> it
>> really easy to toss of simple filter scripts.
> ??
> for line in open(r'c:\bootlog.txt'): print line
I didn't say Python couldn't do it. The nice thing about Perl though is
the fact that while looping over a filehandle, you don't have to
explicitly define a loop variable, because that place is taken by the
default input variable ($_).

That doesn't sound like a big deal, until you see how many Perl functions
can take the default input variable as an argument. Perversely, this can
make for *very* readable code, or total obfuscation.

In fact, the nice thing is that a regexp takes $_ as the default to search
in, so you can just use a bare regexp to search every line of a file in a

I did say that I like both Perl and Python, but Perl really shines when
you start using regexps on streams of data. Python's re module is nice,
but I personally don't like it as much as the way regexps are integrated
in Perl.

I did say I liked the idea of Perl and Python having a common VM, that way
you can use both languages for what they are good at. I do hope that this
will come about eventually.


"Time expands and then contracts
When you're spinning in the grip of someone
Who is not an ordinary girl"
	Counting Crows - Hard Candy

More information about the Python-list mailing list