Opinion on best practice...

Neil Cerutti neilc at norwich.edu
Wed Feb 6 15:20:31 CET 2013


On 2013-02-05, Grant Edwards <invalid at invalid.invalid> wrote:
> On 2013-02-05, Neil Cerutti <neilc at norwich.edu> wrote:
>> On 2013-02-05, Walter Hurry <walterhurry at lavabit.com> wrote:
>>>> Sorry, I'm a Linux guy.  I have no clue what that means.
>>>
>>> Hooray for common sense! Python is great, but it's silly to use
>>> Python (unless there is good reason) when a simple shell script
>>> will do the job.
>>
>> Python is an excellent option for writing shell scripts,
>> particularly if your shell is cmd.exe.
>
> The OP stated explicitly that the target OS was Linux:
>
>>>> I need to pick up a language that would cover the Linux platform.  I
>>>> use Powershell for a scripting language on the Windows side of
>>>> things.
>
> Don't get me wrong -- I think Python is great -- but when the
> target OS is Linux, and what you want to do are file find,
> move, copy, rename, delete operations, then I still say bash
> should be what you try first.

I had Cygwin on my office computer for many years, and wrote
shell scripts to do things like reconcile fund lists from
separate source files, and generate reports of the differences.

Here's the top-level script. Both files have to be preprocessed
before comparing them.

#!/bin/sh
awk -f step1.awk -v arg=$1.spec $1 | sort | awk -f step2.awk > t1.out
awk -f step1.awk -v arg=$2.spec $2 | sort | awk -f step2.awk > t2.out
./recon.pl

I'm bad at shell scripts, obviously (step1? step2? Why doesn't
recon.pl use the command line arguments?). I used several
programs together that I knew only how to read the docs for.
Honestly, my first Python scripts from those days aren't that
much better, and have nearly all been themselves abandoned.

Today I'm much more productive with Python. Virtually all my
programs are data conversion and comparisons, with a good deal of
archiving and batch processing of large groups of files. I can
imagine a programmer who is learned in sh, sed, awk, sort and
sundry who would do just fine at these tasks, but I can't imagine
myself going back.

-- 
Neil Cerutti



More information about the Python-list mailing list