Opinion on best practice...

John Ladasky john_ladasky at sbcglobal.net
Fri Feb 8 22:10:25 EST 2013


On Tuesday, February 5, 2013 5:55:50 PM UTC-8, Steven D'Aprano wrote:

> To do anything meaningful in bash, you need to be an expert on 
> passing work off to other programs...
[snip]
> If you took the Zen of Python, 
> and pretty much reversed everything, you might have the Zen of Bash:

I have to agree.

Recently I needed to write some glue code which would accept some input; run a few Linux command-line programs which were supplied that input; run some Matplotlib scripts of my own to graph the results; and finally, clean up some unwanted intermediate files.

I realized that bash was the "right" way to get the job done... but after struggling with bash for a day, I decided to try Python.  

I wrote a shell script that starts with "#!/usr/bin/env python".  My program imports os, sys, and shlex.split.  I had my first working version within about four hours, even though I had never written a 
command-line Python program before.

Over the next several months, I returned to the program to make several improvements.  I can't imagine maintaining a bash script that does what my Python script does.



More information about the Python-list mailing list