A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/1999-October/001048.html below:

[Python-Dev] getopt helper?

[Python-Dev] getopt helper?Mark Hammond mhammond@skippinet.com.au
Fri, 1 Oct 1999 10:27:03 +1000
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.




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4