python vs awk for simple sysamin tasks

Donn Cave donn at
Thu Jun 3 19:02:26 CEST 2004

In article <slrncbuefv.i05.grey at>,
 Steve Lamb <grey at> wrote:

> On 2004-06-03, Roy Smith <roy at> wrote:
> > Neither of these are really tasks well suited to python at all.
>     Individually, no.  Combined, yes.
> > I'm sure you could replicate this functionality in python using things 
> > like os.walk() and os.stat(), but why bother?  The result would be no 
> > better than the quick on-liners you've got above. 
>     Not true.  The above one liners are two passes over the same data.  With
> an appropriate script you could make one pass and get both results.  Sure you
> could do that in shell but I'm of the opinion that anything other than one
> liners should never be done in shell.

I guess you're already conceding that your own point isn't
very relevant, but just in case this isn't clear, if the
intent was actually to do both tasks at the same time (which
isn't clear), the end clause could easily print the sum and
then the average.  (The example erroneously fails to label
the end clause, but it should be fairly easy to see what was

Awk is a nice language for its intended role - concise,
readable, efficient -  and I use it a lot for things like
this, or somewhat more elaborate programs, because I believe
it's easier for my colleagues to deal with who aren't familiar
with Python (or awk, really.)  It's also supported by the
UNIX platforms we use, as long as I avoid gawk-isms, while
Python will never be really reliably present until it can
stabilize enough that a platform vendor isn't signing on
for a big headache by trying to support it.  (Wave and say
hi, Redhat.)

However, it's inadequate for complex programming - can't
store arrays in arrays, for example.

   Donn Cave, donn at

More information about the Python-list mailing list