Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Doc/library/getopt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ exception:
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 (``'='``).
Long options which take an optional argument should be followed by
Long options which acept an optional argument should be followed by
an equal sign and question mark (``'=?'``).
To accept only long options, *shortopts* should be an
empty string. Long options on the command line can be recognized so long as
Expand Down Expand Up @@ -132,6 +132,8 @@ Using long option names is equally easy:

Optional arguments should be specified explicitly:

.. doctest::

>>> s = '-Con -C --color=off --color a1 a2'
>>> args = s.split()
>>> args
Expand All @@ -142,7 +144,9 @@ Optional arguments should be specified explicitly:
>>> args
['a1', 'a2']

In a script, typical usage is something like this::
In a script, typical usage is something like this:

.. testcode::

import getopt, sys

Expand Down
6 changes: 4 additions & 2 deletions Lib/getopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ def getopt(args, shortopts, longopts = []):
running program. Typically, this 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 getopt() uses). If
colon and options that accept an optional argument followed by
two colons (i.e., the same format that Unix getopt() uses). If
specified, longopts is 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. Options
which require an argument should be followed by an equal sign
('=').
('='). Options which acept an optional argument should be
followed by an equal sign and question mark ('=?').

The return value consists of two elements: the first is a list of
(option, value) pairs; the second is the list of program arguments
Expand Down
Loading