[BangPypers] Command line goodies

Anand Chitipothu anandology at gmail.com
Wed Mar 25 17:29:46 CET 2009


> Really ? FYI, Python is full of one-liners both of the command-line
> variety and the code variety.

I don't agree. It is painful to write command liners with python.

Look at this perl one liner that replaces .py with .txt.

ls *.py | perl -ne 's/.py$/.txt/; print $_;'

Try writing it in Python and you will know how painful it is.

Also Python doesn't go well with pipes. For example, the following
code produces an error.

python -c 'while True: print "hello"' | head -1

But its perl equivalent doesn't.

perl -e 'while(1) { print "hello\n"; }' | head -1

-Anand


More information about the BangPypers mailing list