[Chicago] __name__ == "__main__"

skip at pobox.com skip at pobox.com
Sat Oct 27 22:12:14 CEST 2007

    mt> Nitpicking, I think Skip's is imperfectly from memory since

    mt>            opts, args = getopt.getopt(args, "h", ["help"])

    mt> doesn't seem to match

    mt>        for opt, arg in opts:

Ah, but it does match.  It's just what Guido had in his blog post (except he
spelled "opt" and "arg" as "o" and "a").  getopt.getopt splits the words on
the command line into two groups, the options and the arguments.  You then
step through the options which are of the form:

    [(o1, a1), (o2, a2), ...]

I am old enough to know I can no longer rely on my memory for things like
this.  I actually have ~/src/script-tmpl.py which I use to start new scripts
(when my memory doesn't fail me and I don't remember I have it or can't
remember where I put it.  That's what I pasted into my mail message. ;-)


More information about the Chicago mailing list