Please rate my scripts.

Jonathan Ellis jonathan at
Mon Apr 14 16:25:44 MDT 2008

On Mon, Apr 14, 2008 at 10:15 AM, Michael Torrie <torriem at> wrote:
>  How "pythonic do you want your script?  Here are a couple of points:
>  - None of your scripts have any comments at all.  Shell scripting in
>  particular requires many comments, in my experience.
>  - Only ever compile your regex's once if you can help it.  Looks to me
>  like filter should be defined right at the top.

the re module will invisibly cache the most recent 100 expressions for
you, which is usually plenty.  so this is fine.

>  - In any language, including bash, I highly recommend using getopt to
>  provide simple command line help and rudimentary switch processing if
>  needed (which it's not in this case).

in python, optparse is more modern and generally better than getopt.

Also: prefer the subprocess module to os.system and os.popen.  Use the
list-of-args functions instead of throwing everything into a string
manually; this will save your butt eventually when you run into
quoting fun.

Minor point: inconsistent spacing around parens and operators is
confusing.  Sometimes you have extra spaces, sometimes not.  Anything
is okay as long as you're consistent, but almost all Python code
follows "the python style guide" (pep 8) which recommends spacing
around binary operators and no extra spaces inside parens.


More information about the PLUG mailing list