summaryrefslogtreecommitdiffstats
path: root/Doc/library/getopt.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-05-17 13:00:36 (GMT)
committerGeorg Brandl <georg@python.org>2009-05-17 13:00:36 (GMT)
commit036490d025b768c9e69567c3caac63ccd7a62a09 (patch)
treeaeb86dff3b316514ee06be484fe0e482bcd83a12 /Doc/library/getopt.rst
parentcd86925b3bb994a8b2662cbe04be356768df5e86 (diff)
downloadcpython-036490d025b768c9e69567c3caac63ccd7a62a09.zip
cpython-036490d025b768c9e69567c3caac63ccd7a62a09.tar.gz
cpython-036490d025b768c9e69567c3caac63ccd7a62a09.tar.bz2
More conversion to new-style optional args.
Diffstat (limited to 'Doc/library/getopt.rst')
-rw-r--r--Doc/library/getopt.rst23
1 files changed, 11 insertions, 12 deletions
diff --git a/Doc/library/getopt.rst b/Doc/library/getopt.rst
index 94ba90e..7f6b670 100644
--- a/Doc/library/getopt.rst
+++ b/Doc/library/getopt.rst
@@ -1,10 +1,9 @@
-
:mod:`getopt` --- Parser for command line options
=================================================
.. module:: getopt
- :synopsis: Portable parser for command line options; support both short and long option
- names.
+ :synopsis: Portable parser for command line options; support both short and
+ long option names.
This module helps scripts to parse the command line arguments in ``sys.argv``.
@@ -20,27 +19,27 @@ This module provides two functions and an
exception:
-.. function:: getopt(args, options[, long_options])
+.. function:: getopt(args, shortopts, longopts=[])
Parses command line options and parameter list. *args* is the argument list to
be parsed, without the leading reference to the running program. Typically, this
- means ``sys.argv[1:]``. *options* is the string of option letters that the
+ means ``sys.argv[1:]``. *shortopts* is the string of option letters that the
script wants to recognize, with options that require an argument followed by a
colon (``':'``; i.e., the same format that Unix :cfunc:`getopt` uses).
.. note::
- Unlike GNU :cfunc:`getopt`, after a non-option argument, all further arguments
- are considered also non-options. This is similar to the way non-GNU Unix systems
- work.
+ Unlike GNU :cfunc:`getopt`, after a non-option argument, all further
+ arguments are considered also non-options. This is similar to the way
+ non-GNU Unix systems work.
- *long_options*, if specified, must be a list of strings with the names of the
+ *longopts*, if specified, must be a list of strings with the names of the
long options which should be supported. The leading ``'--'`` characters
should not be included in the option name. Long options which require an
argument should be followed by an equal sign (``'='``). To accept only long
- options, *options* should be an empty string. Long options on the command line
+ options, *shortopts* should be an empty string. Long options on the command line
can be recognized so long as they provide a prefix of the option name that
- matches exactly one of the accepted options. For example, if *long_options* is
+ matches exactly one of the accepted options. For example, if *longopts* is
``['foo', 'frob']``, the option :option:`--fo` will match as :option:`--foo`,
but :option:`--f` will not match uniquely, so :exc:`GetoptError` will be raised.
@@ -55,7 +54,7 @@ exception:
allowing multiple occurrences. Long and short options may be mixed.
-.. function:: gnu_getopt(args, options[, long_options])
+.. function:: gnu_getopt(args, shortopts, longopts=[])
This function works like :func:`getopt`, except that GNU style scanning mode is
used by default. This means that option and non-option arguments may be