
OK - general agreement. Wheee :-) How about this: def getopt_or_die(opts, long_opts=[], usage=None, prog_name=None, args=None, exit_code = 1): if usage is None, we build a very simple usage string from opts/long_opts. If prog_name is None, we use os.path.basename(sys.argv[0]). This is printed just before the usage message. If args is None, we use sys.argv[1:] exit_code specifies the param to sys.exit() on invalid options. I have based the ordering on my guess at the most likely to be used - but maybe "prog_name" and "args" should be reversed? This should _not_ be all-singing, all-dancing, as it is simple to use the existing getopt.getopt() directly for more esoteric requirements; the old 80-20 rule applies here :-) If the general agreement continues, I will then knock together an implementation. Mark.