sys.stdin.readline()

Peter Hansen peter at engcorp.com
Wed Sep 1 08:25:27 EDT 2004


Mike Maxwell wrote:

> Alex Martelli wrote:
>> Mike Maxwell <maxwell at ldc.upenn.edu> wrote:
>> No, I think you're correctly observing that Python isn't oriented to
>> one-liners -- not at all.  Most interesting things in Python require
>> more than one line.  
> 
> <rant>
> I don't care whether it's "interesting", I just want to get some work 
> done.  And since most of the text processing tools in Unixes that I 
> would otherwise use (grep, sed, tr) don't support Unicode, and are 
> inconsistent in their regular expression notation to boot, it would be 
> nice if I could write regex operations in a single, consistent 
> programming language.  Python is a single, consistent programming 
> language, but as you say, it doesn't lend itself to one-liners.
> </rant>

Most of us who do this conclude that our potential one-liner
is actually likely to be re-used, and we write the Python
three-liner equivalent in a file.  Later on, we typically find
that it has grown to seventeen lines and we don't particularly
mind the slight extra inconvenience of having to put the
initial code in a file instead of trying to retype it each
time we need it.

-Peter



More information about the Python-list mailing list