[Python-checkins] python/dist/src/Lib getopt.py,1.17,1.18

Neal Norwitz neal@metaslash.com
Thu, 06 Jun 2002 09:17:45 -0400


loewis@users.sourceforge.net wrote:
> 
> Modified Files:
>         getopt.py
> Log Message:
> Patch 473512: add GNU style scanning as gnu_getopt.
> 
> Index: getopt.py
> ===================================================================
> RCS file: /cvsroot/python/python/dist/src/Lib/getopt.py,v
> +
> + def gnu_getopt(args, shortopts, longopts = []):
> +     opts = []
> +     prog_args = []
> +     if type(longopts) == type(""):
> +         longopts = [longopts]
> +     else:
> +         longopts = list(longopts)
> +
> +     # Allow options after non-option arguments?
> +     if shortopts.startswith('+'):
> +         shortopts = shortopts[1:]
> +         all_options_first = 1
> +     elif os.getenv("POSIXLY_CORRECT"):
> +         all_options_first = 1
> +     else:
> +         all_options_first = 0

For additions to the stdlib, should we try to make sure new features
are used?  In the above code, type(longopts) ... -> isinstance(longopts, str)
(or basestring?) and all_options_first could be a bool.

Neal