chunk_id stringlengths 36 36 | source stringclasses 35
values | source_url stringlengths 0 290 | upstream_license stringclasses 1
value | document_id stringlengths 36 36 | chunk_index int64 0 324k | retrieved_at stringclasses 2
values | chunker_version stringclasses 4
values | content_hash stringlengths 15 64 | content stringlengths 50 44.7k | namespace stringclasses 9
values | source_name stringclasses 35
values | raw_text stringlengths 50 44.7k | cleaned_text stringlengths 50 44.7k | tags stringclasses 49
values | collection_name stringclasses 11
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
090c7915-7c9e-4985-a78b-e824ef1737dc | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,926 | supabase-export-v2 | 138db6ab1a584e34 | However, the ``argparse`` version will also handle some parameter combination differently from the way the ``optparse`` version would handle them. For example (amongst other differences):
* supplying ``-o -v`` gives ``output="-v"`` and ``verbose=False``
when using ``optparse``, but a usage error with ``argparse``
(co... | trusted_official_docs | CPython Docs | However, the ``argparse`` version will also handle some parameter combination differently from the way the ``optparse`` version would handle them. For example (amongst other differences):
* supplying ``-o -v`` gives ``output="-v"`` and ``verbose=False``
when using ``optparse``, but a usage error with ``argparse``
(co... | However, the ``argparse`` version will also handle some parameter combination differently from the way the ``optparse`` version would handle them. For example (amongst other differences):
* supplying ``-o -v`` gives ``output="-v"`` and ``verbose=False``
when using ``optparse``, but a usage error with ``argparse``
(co... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0a30cf41-1d82-4873-b311-e32ec89b8cd0 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,480 | supabase-export-v2 | 65a8e3df6ff49caa | .. attribute:: Option.ALWAYS_TYPED_ACTIONS
Actions that always take a type (i.e. whose options always take a value) are
additionally listed here. The only effect of this is that :mod:`!optparse`
assigns the default type, ``"string"``, to options with no explicit type
whose action is listed in :attr:`ALWAYS_TYPED_ACT... | trusted_official_docs | CPython Docs | .. attribute:: Option.ALWAYS_TYPED_ACTIONS
Actions that always take a type (i.e. whose options always take a value) are
additionally listed here. The only effect of this is that :mod:`!optparse`
assigns the default type, ``"string"``, to options with no explicit type
whose action is listed in :attr:`ALWAYS_TYPED_ACT... | .. attribute:: Option.ALWAYS_TYPED_ACTIONS
Actions that always take a type (i.e. whose options always take a value) are
additionally listed here. The only effect of this is that :mod:`!optparse`
assigns the default type, ``"string"``, to options with no explicit type
whose action is listed in :attr:`ALWAYS_TYPED_ACT... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0ac8456a-acf8-4429-8aac-93218d073327 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,052 | supabase-export-v2 | 9b8cf8d88000c3d3 | help="be vewwy quiet (I'm hunting wabbits)") parser.add_option("-f", "--filename", metavar="FILE", help="write output to FILE") parser.add_option("-m", "--mode", default="intermediate", help="interaction mode: novice, intermediate, " "or expert [default: %default]")
If :mod:`!optparse` encounters either ``-h`` or ``--h... | trusted_official_docs | CPython Docs | help="be vewwy quiet (I'm hunting wabbits)") parser.add_option("-f", "--filename", metavar="FILE", help="write output to FILE") parser.add_option("-m", "--mode", default="intermediate", help="interaction mode: novice, intermediate, " "or expert [default: %default]")
If :mod:`!optparse` encounters either ``-h`` or ``--h... | help="be vewwy quiet (I'm hunting wabbits)") parser.add_option("-f", "--filename", metavar="FILE", help="write output to FILE") parser.add_option("-m", "--mode", default="intermediate", help="interaction mode: novice, intermediate, " "or expert [default: %default]")
If :mod:`!optparse` encounters either ``-h`` or ``--h... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0ae54ef5-c7ab-472e-a73c-922263f032bc | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,979 | supabase-export-v2 | 60be730d1749cfc3 | Positional arguments are for those pieces of information that your program absolutely, positively requires to run.
A good user interface should have as few absolute requirements as possible. If
your program requires 17 distinct pieces of information in order to run
successfully, it doesn't much matter *how* you get tha... | trusted_official_docs | CPython Docs | Positional arguments are for those pieces of information that your program absolutely, positively requires to run.
A good user interface should have as few absolute requirements as possible. If
your program requires 17 distinct pieces of information in order to run
successfully, it doesn't much matter *how* you get tha... | Positional arguments are for those pieces of information that your program absolutely, positively requires to run.
A good user interface should have as few absolute requirements as possible. If
your program requires 17 distinct pieces of information in order to run
successfully, it doesn't much matter *how* you get tha... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0b421bd1-807f-45d9-bbe7-c0fb2588cbad | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,378 | supabase-export-v2 | 7f92ec9b99f56f0a | might want your callback to consume an arbitrary number of command-line arguments. This is where writing callbacks gets tricky; it's covered later in this section.
:mod:`!optparse` always passes four particular arguments to your callback, and it
will only pass additional arguments if you specify them via
:attr:`~Option... | trusted_official_docs | CPython Docs | might want your callback to consume an arbitrary number of command-line arguments. This is where writing callbacks gets tricky; it's covered later in this section.
:mod:`!optparse` always passes four particular arguments to your callback, and it
will only pass additional arguments if you specify them via
:attr:`~Option... | might want your callback to consume an arbitrary number of command-line arguments. This is where writing callbacks gets tricky; it's covered later in this section.
:mod:`!optparse` always passes four particular arguments to your callback, and it
will only pass additional arguments if you specify them via
:attr:`~Option... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0c050e1c-c5e6-4c03-8ca7-2c959cb81023 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,101 | supabase-export-v2 | 49c6bcd9265b8a67 | brief usage string, :mod:`!optparse` can also print a version string for your program. You have to supply the string as the ``version`` argument to OptionParser::
parser = OptionParser(usage="%prog [-f] [-q]", version="%prog 1.0") | trusted_official_docs | CPython Docs | brief usage string, :mod:`!optparse` can also print a version string for your program. You have to supply the string as the ``version`` argument to OptionParser::
parser = OptionParser(usage="%prog [-f] [-q]", version="%prog 1.0") | brief usage string, :mod:`!optparse` can also print a version string for your program. You have to supply the string as the ``version`` argument to OptionParser::
parser = OptionParser(usage="%prog [-f] [-q]", version="%prog 1.0") | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0cfd5b61-4399-4762-8aa0-dcb436a24e6a | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,181 | supabase-export-v2 | 1dcc1a2231d52c9f | created by calling when calling :meth:`OptionParser.parse_args`, and can be overridden by a custom subclass passed to the *values* argument of :meth:`OptionParser.parse_args` (as described in :ref:`optparse-parsing-arguments`).
Option
arguments (and various other values) are stored as attributes of this object,
accordi... | trusted_official_docs | CPython Docs | created by calling when calling :meth:`OptionParser.parse_args`, and can be overridden by a custom subclass passed to the *values* argument of :meth:`OptionParser.parse_args` (as described in :ref:`optparse-parsing-arguments`).
Option
arguments (and various other values) are stored as attributes of this object,
accordi... | created by calling when calling :meth:`OptionParser.parse_args`, and can be overridden by a custom subclass passed to the *values* argument of :meth:`OptionParser.parse_args` (as described in :ref:`optparse-parsing-arguments`).
Option
arguments (and various other values) are stored as attributes of this object,
accordi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0da2ea9e-6325-4f76-ad60-7bfba16cef58 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,454 | supabase-export-v2 | dcdbc2c08a5e5087 | as-is to :class:`OptionParser`'s :meth:`error` method, which in turn prepends the program name and the string ``"error:"`` and prints everything to stderr before terminating the process.
Here's a silly example that demonstrates adding a ``"complex"`` option type to
parse Python-style complex numbers on the command line... | trusted_official_docs | CPython Docs | as-is to :class:`OptionParser`'s :meth:`error` method, which in turn prepends the program name and the string ``"error:"`` and prints everything to stderr before terminating the process.
Here's a silly example that demonstrates adding a ``"complex"`` option type to
parse Python-style complex numbers on the command line... | as-is to :class:`OptionParser`'s :meth:`error` method, which in turn prepends the program name and the string ``"error:"`` and prints everything to stderr before terminating the process.
Here's a silly example that demonstrates adding a ``"complex"`` option type to
parse Python-style complex numbers on the command line... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0dba9aaa-7129-477c-95aa-a03f501d07dc | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,982 | supabase-export-v2 | 0cdb96bc1d00f561 | Tutorial --------
While :mod:`!optparse` is quite flexible and powerful, it's also straightforward
to use in most cases. This section covers the code patterns that are common to
any :mod:`!optparse`\ -based program. | trusted_official_docs | CPython Docs | Tutorial --------
While :mod:`!optparse` is quite flexible and powerful, it's also straightforward
to use in most cases. This section covers the code patterns that are common to
any :mod:`!optparse`\ -based program. | Tutorial --------
While :mod:`!optparse` is quite flexible and powerful, it's also straightforward
to use in most cases. This section covers the code patterns that are common to
any :mod:`!optparse`\ -based program. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0df828e8-6b8a-41bd-aa85-31c0d5b1b99c | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,433 | supabase-export-v2 | d89494052115bec4 | * bare ``--`` (if not the argument to some option): halt command-line processing and discard the ``--``
* bare ``-`` (if not the argument to some option): halt command-line
processing but keep the ``-`` (append it to ``parser.largs``) | trusted_official_docs | CPython Docs | * bare ``--`` (if not the argument to some option): halt command-line processing and discard the ``--``
* bare ``-`` (if not the argument to some option): halt command-line
processing but keep the ``-`` (append it to ``parser.largs``) | * bare ``--`` (if not the argument to some option): halt command-line processing and discard the ``--``
* bare ``-`` (if not the argument to some option): halt command-line
processing but keep the ``-`` (append it to ``parser.largs``) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0f71ffe2-c3e4-43eb-8e10-c7e43cf6d73c | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,087 | supabase-export-v2 | 57a03b6a51e51fd2 | OptionGroup(parser, "Dangerous Options", "Caution: use these options at your own risk. " "It is believed that some of them bite.") group.add_option("-g", action="store_true", help="Group option.") parser.add_option_group(group)
group = OptionGroup(parser, "Debug Options")
group.add_option("-d", "--debug", action="stor... | trusted_official_docs | CPython Docs | OptionGroup(parser, "Dangerous Options", "Caution: use these options at your own risk. " "It is believed that some of them bite.") group.add_option("-g", action="store_true", help="Group option.") parser.add_option_group(group)
group = OptionGroup(parser, "Debug Options")
group.add_option("-d", "--debug", action="stor... | OptionGroup(parser, "Dangerous Options", "Caution: use these options at your own risk. " "It is believed that some of them bite.") group.add_option("-g", action="store_true", help="Group option.") parser.add_option_group(group)
group = OptionGroup(parser, "Debug Options")
group.add_option("-d", "--debug", action="stor... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
10affab9-3696-4b90-b6be-72471864b045 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,250 | supabase-export-v2 | ec2b2ed97920e371 | * ``"append"`` [relevant: :attr:`~Option.type`, :attr:`~Option.dest`, :attr:`~Option.nargs`, :attr:`~Option.choices`]
The option must be followed by an argument, which is appended to the list in
:attr:`~Option.dest`. If no default value for :attr:`~Option.dest` is
supplied, an empty list is automatically created when... | trusted_official_docs | CPython Docs | * ``"append"`` [relevant: :attr:`~Option.type`, :attr:`~Option.dest`, :attr:`~Option.nargs`, :attr:`~Option.choices`]
The option must be followed by an argument, which is appended to the list in
:attr:`~Option.dest`. If no default value for :attr:`~Option.dest` is
supplied, an empty list is automatically created when... | * ``"append"`` [relevant: :attr:`~Option.type`, :attr:`~Option.dest`, :attr:`~Option.nargs`, :attr:`~Option.choices`]
The option must be followed by an argument, which is appended to the list in
:attr:`~Option.dest`. If no default value for :attr:`~Option.dest` is
supplied, an empty list is automatically created when... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
129f7a99-371e-4ce5-8194-64cc641c500d | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,957 | supabase-export-v2 | a61addc6f156c680 | * a plus sign followed by a single letter, or a few letters, or a word, e.g. ``+f``, ``+rgb``
* a slash followed by a letter, or a few letters, or a word, e.g. ``/f``,
``/file`` | trusted_official_docs | CPython Docs | * a plus sign followed by a single letter, or a few letters, or a word, e.g. ``+f``, ``+rgb``
* a slash followed by a letter, or a few letters, or a word, e.g. ``/f``,
``/file`` | * a plus sign followed by a single letter, or a few letters, or a word, e.g. ``+f``, ``+rgb``
* a slash followed by a letter, or a few letters, or a word, e.g. ``/f``,
``/file`` | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1375fef3-e281-4404-9753-a3617e5ef41d | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,147 | supabase-export-v2 | bc05ad388a432ec3 | ``add_help_option`` (default: ``True``) If true, :mod:`!optparse` will add a help option (with option strings ``-h`` and ``--help``) to the parser.
``prog``
The string to use when expanding ``%prog`` in ``usage`` and ``version``
instead of ``os.path.basename(sys.argv[0])``. | trusted_official_docs | CPython Docs | ``add_help_option`` (default: ``True``) If true, :mod:`!optparse` will add a help option (with option strings ``-h`` and ``--help``) to the parser.
``prog``
The string to use when expanding ``%prog`` in ``usage`` and ``version``
instead of ``os.path.basename(sys.argv[0])``. | ``add_help_option`` (default: ``True``) If true, :mod:`!optparse` will add a help option (with option strings ``-h`` and ``--help``) to the parser.
``prog``
The string to use when expanding ``%prog`` in ``usage`` and ``version``
instead of ``os.path.basename(sys.argv[0])``. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
14a6dcbd-012b-4cef-b3aa-92a544f7a032 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,152 | supabase-export-v2 | 2af751c635c69d10 | the parser with options. The preferred way is by using :meth:`OptionParser.add_option`, as shown in section :ref:`optparse-tutorial`. :meth:`add_option` can be called in one of two ways:
* pass it an Option instance (as returned by :func:`make_option`) | trusted_official_docs | CPython Docs | the parser with options. The preferred way is by using :meth:`OptionParser.add_option`, as shown in section :ref:`optparse-tutorial`. :meth:`add_option` can be called in one of two ways:
* pass it an Option instance (as returned by :func:`make_option`) | the parser with options. The preferred way is by using :meth:`OptionParser.add_option`, as shown in section :ref:`optparse-tutorial`. :meth:`add_option` can be called in one of two ways:
* pass it an Option instance (as returned by :func:`make_option`) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
15b6771b-4e55-44e9-8c9f-b464332dcf50 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,159 | supabase-export-v2 | b19f4682881d016e | Defining options ^^^^^^^^^^^^^^^^
Each Option instance represents a set of synonymous command-line option strings,
e.g. ``-f`` and ``--file``. You can specify any number of short or
long option strings, but you must specify at least one overall option string. | trusted_official_docs | CPython Docs | Defining options ^^^^^^^^^^^^^^^^
Each Option instance represents a set of synonymous command-line option strings,
e.g. ``-f`` and ``--file``. You can specify any number of short or
long option strings, but you must specify at least one overall option string. | Defining options ^^^^^^^^^^^^^^^^
Each Option instance represents a set of synonymous command-line option strings,
e.g. ``-f`` and ``--file``. You can specify any number of short or
long option strings, but you must specify at least one overall option string. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
16203274-a2c4-4742-8eaa-581af5af1377 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,411 | supabase-export-v2 | 7674c068e1e1262c | Callback example 2: check option order ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Here's a slightly more interesting example: record the fact that ``-a`` is
seen, but blow up if it comes after ``-b`` in the command-line. :: | trusted_official_docs | CPython Docs | Callback example 2: check option order ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Here's a slightly more interesting example: record the fact that ``-a`` is
seen, but blow up if it comes after ``-b`` in the command-line. :: | Callback example 2: check option order ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Here's a slightly more interesting example: record the fact that ``-a`` is
seen, but blow up if it comes after ``-b`` in the command-line. :: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1657aaf0-a467-4493-8cdc-ad3610624ea4 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,965 | supabase-export-v2 | 94cbcf8e1c52f8c2 | leftover in the argument list after options have been parsed, i.e. after options and their arguments have been parsed and removed from the argument list.
required option
an option that must be supplied on the command-line; note that the phrase
"required option" is self-contradictory in English. :mod:`!optparse` doesn... | trusted_official_docs | CPython Docs | leftover in the argument list after options have been parsed, i.e. after options and their arguments have been parsed and removed from the argument list.
required option
an option that must be supplied on the command-line; note that the phrase
"required option" is self-contradictory in English. :mod:`!optparse` doesn... | leftover in the argument list after options have been parsed, i.e. after options and their arguments have been parsed and removed from the argument list.
required option
an option that must be supplied on the command-line; note that the phrase
"required option" is self-contradictory in English. :mod:`!optparse` doesn... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
16b1414f-f0df-451b-bc77-0a9ecb2cc62e | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,398 | supabase-export-v2 | 3e4c43e95204bbbb | don't need to mess around with globals or closures. You can also access or modify the value(s) of any options already encountered on the command-line.
``args``
is a tuple of arbitrary positional arguments supplied via the
:attr:`~Option.callback_args` option attribute. | trusted_official_docs | CPython Docs | don't need to mess around with globals or closures. You can also access or modify the value(s) of any options already encountered on the command-line.
``args``
is a tuple of arbitrary positional arguments supplied via the
:attr:`~Option.callback_args` option attribute. | don't need to mess around with globals or closures. You can also access or modify the value(s) of any options already encountered on the command-line.
``args``
is a tuple of arbitrary positional arguments supplied via the
:attr:`~Option.callback_args` option attribute. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
17113b9d-fecc-4d4f-ae72-d563c90da241 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,070 | supabase-export-v2 | 7444c5aeb2f77007 | Grouping Options ++++++++++++++++
When dealing with many options, it is convenient to group these options for
better help output. An :class:`OptionParser` can contain several option groups,
each of which can contain several options. | trusted_official_docs | CPython Docs | Grouping Options ++++++++++++++++
When dealing with many options, it is convenient to group these options for
better help output. An :class:`OptionParser` can contain several option groups,
each of which can contain several options. | Grouping Options ++++++++++++++++
When dealing with many options, it is convenient to group these options for
better help output. An :class:`OptionParser` can contain several option groups,
each of which can contain several options. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
173d7005-c881-4a4b-b823-b97665986d44 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,002 | supabase-export-v2 | 2b33362df05d8ec3 | tell :mod:`!optparse` to store a value in some variable---for example, take a string from the command line and store it in an attribute of ``options``.
If you don't specify an option action, :mod:`!optparse` defaults to ``store``. | trusted_official_docs | CPython Docs | tell :mod:`!optparse` to store a value in some variable---for example, take a string from the command line and store it in an attribute of ``options``.
If you don't specify an option action, :mod:`!optparse` defaults to ``store``. | tell :mod:`!optparse` to store a value in some variable---for example, take a string from the command line and store it in an attribute of ``options``.
If you don't specify an option action, :mod:`!optparse` defaults to ``store``. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
177423a0-29e8-4e24-bbb8-c05e4c075b1d | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,950 | supabase-export-v2 | 28ff83c37d010275 | Terminology ^^^^^^^^^^^
argument
a string entered on the command-line, and passed by the shell to ``execl()``
or ``execv()``. In Python, arguments are elements of ``sys.argv[1:]``
(``sys.argv[0]`` is the name of the program being executed). Unix shells
also use the term "word". | trusted_official_docs | CPython Docs | Terminology ^^^^^^^^^^^
argument
a string entered on the command-line, and passed by the shell to ``execl()``
or ``execv()``. In Python, arguments are elements of ``sys.argv[1:]``
(``sys.argv[0]`` is the name of the program being executed). Unix shells
also use the term "word". | Terminology ^^^^^^^^^^^
argument
a string entered on the command-line, and passed by the shell to ``execl()``
or ``execv()``. In Python, arguments are elements of ``sys.argv[1:]``
(``sys.argv[0]`` is the name of the program being executed). Unix shells
also use the term "word". | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
180c81be-8349-4c5e-b194-13a7f92ba5f4 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,948 | supabase-export-v2 | ba1fded802c9b3af | Background ----------
:mod:`!optparse` was explicitly designed to encourage the creation of programs
with straightforward command-line interfaces that follow the conventions
established by the :c:func:`!getopt` family of functions available to C developers. To that end, it supports only the most common command-line syn... | trusted_official_docs | CPython Docs | Background ----------
:mod:`!optparse` was explicitly designed to encourage the creation of programs
with straightforward command-line interfaces that follow the conventions
established by the :c:func:`!getopt` family of functions available to C developers. To that end, it supports only the most common command-line syn... | Background ----------
:mod:`!optparse` was explicitly designed to encourage the creation of programs
with straightforward command-line interfaces that follow the conventions
established by the :c:func:`!getopt` family of functions available to C developers. To that end, it supports only the most common command-line syn... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
180e4daa-22dc-4b46-9d73-a5720e13d6b6 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,308 | supabase-export-v2 | 5eece3a65d6c305b | option arguments in (default: a new instance of :class:`Values`) -- if you give an existing object, the option defaults will not be initialized on it
and the return value is a pair ``(options, args)`` where | trusted_official_docs | CPython Docs | option arguments in (default: a new instance of :class:`Values`) -- if you give an existing object, the option defaults will not be initialized on it
and the return value is a pair ``(options, args)`` where | option arguments in (default: a new instance of :class:`Values`) -- if you give an existing object, the option defaults will not be initialized on it
and the return value is a pair ``(options, args)`` where | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1ab73e3c-1d6a-4d7b-951c-fbc3864c9b2a | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,045 | supabase-export-v2 | fa6b611fc464ab73 | Again, the default value for ``verbose`` will be ``True``: the last default value supplied for any particular destination is the one that counts.
A clearer way to specify default values is the :meth:`set_defaults` method of
OptionParser, which you can call at any time before calling
:meth:`~OptionParser.parse_args`:: | trusted_official_docs | CPython Docs | Again, the default value for ``verbose`` will be ``True``: the last default value supplied for any particular destination is the one that counts.
A clearer way to specify default values is the :meth:`set_defaults` method of
OptionParser, which you can call at any time before calling
:meth:`~OptionParser.parse_args`:: | Again, the default value for ``verbose`` will be ``True``: the last default value supplied for any particular destination is the one that counts.
A clearer way to specify default values is the :meth:`set_defaults` method of
OptionParser, which you can call at any time before calling
:meth:`~OptionParser.parse_args`:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1c1d3050-cd8e-40b7-be52-bd9c9189891b | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,055 | supabase-export-v2 | 51100af7011429f5 | Usage: <yourscript> [options] arg1 arg2
Options:
-h, --help show this help message and exit
-v, --verbose make lots of noise [default]
-q, --quiet be vewwy quiet (I'm hunting wabbits)
-f FILE, --filename=FILE
write output to FILE
-m MODE, --mode=MODE interaction mode: novice, intermediate, or
expert [default: in... | trusted_official_docs | CPython Docs | Usage: <yourscript> [options] arg1 arg2
Options:
-h, --help show this help message and exit
-v, --verbose make lots of noise [default]
-q, --quiet be vewwy quiet (I'm hunting wabbits)
-f FILE, --filename=FILE
write output to FILE
-m MODE, --mode=MODE interaction mode: novice, intermediate, or
expert [default: in... | Usage: <yourscript> [options] arg1 arg2
Options:
-h, --help show this help message and exit
-v, --verbose make lots of noise [default]
-q, --quiet be vewwy quiet (I'm hunting wabbits)
-f FILE, --filename=FILE
write output to FILE
-m MODE, --mode=MODE interaction mode: novice, intermediate, or
expert [default: in... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1d87d4cd-8b72-4776-96ce-0cc67c80eb38 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,276 | supabase-export-v2 | f2f804d26144c654 | the current option parser. The help message is constructed from the ``usage`` string passed to OptionParser's constructor and the :attr:`~Option.help` string passed to every option.
If no :attr:`~Option.help` string is supplied for an option, it will still be
listed in the help message. To omit an option entirely, use... | trusted_official_docs | CPython Docs | the current option parser. The help message is constructed from the ``usage`` string passed to OptionParser's constructor and the :attr:`~Option.help` string passed to every option.
If no :attr:`~Option.help` string is supplied for an option, it will still be
listed in the help message. To omit an option entirely, use... | the current option parser. The help message is constructed from the ``usage`` string passed to OptionParser's constructor and the :attr:`~Option.help` string passed to every option.
If no :attr:`~Option.help` string is supplied for an option, it will still be
listed in the help message. To omit an option entirely, use... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
206cc8c9-cf75-4fda-9cac-8e54671ed568 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,275 | supabase-export-v2 | ff0eb5d59c409ad3 | * ``"help"``
Prints a complete help message for all the options in the current option
parser. The help message is constructed from the ``usage`` string passed to
OptionParser's constructor and the :attr:`~Option.help` string passed to every
option. | trusted_official_docs | CPython Docs | * ``"help"``
Prints a complete help message for all the options in the current option
parser. The help message is constructed from the ``usage`` string passed to
OptionParser's constructor and the :attr:`~Option.help` string passed to every
option. | * ``"help"``
Prints a complete help message for all the options in the current option
parser. The help message is constructed from the ``usage`` string passed to
OptionParser's constructor and the :attr:`~Option.help` string passed to every
option. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
21eee9a4-a6fb-4470-b172-cc19d6916068 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,913 | supabase-export-v2 | 3fc66d85e8b654a5 | The standard library includes three argument parsing libraries:
* :mod:`getopt`: a module that closely mirrors the procedural C ``getopt`` API. Included in the standard library since before the initial Python 1.0 release. * :mod:`!optparse`: a declarative replacement for ``getopt`` that
provides equivalent functionali... | trusted_official_docs | CPython Docs | The standard library includes three argument parsing libraries:
* :mod:`getopt`: a module that closely mirrors the procedural C ``getopt`` API. Included in the standard library since before the initial Python 1.0 release. * :mod:`!optparse`: a declarative replacement for ``getopt`` that
provides equivalent functionali... | The standard library includes three argument parsing libraries:
* :mod:`getopt`: a module that closely mirrors the procedural C ``getopt`` API. Included in the standard library since before the initial Python 1.0 release. * :mod:`!optparse`: a declarative replacement for ``getopt`` that
provides equivalent functionali... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2409bffd-a2ae-4aa7-aaa1-1d231aa9f238 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,259 | supabase-export-v2 | 2762d445dbf5243c | the default elements will be present in the parsed value for the option, with any values from the command line appended after those default values::
>>> parser.add_option("--files", action="append", default=['~/.mypkg/defaults'])
>>> opts, args = parser.parse_args(['--files', 'overrides.mypkg'])
>>> opts.files
['~/.... | trusted_official_docs | CPython Docs | the default elements will be present in the parsed value for the option, with any values from the command line appended after those default values::
>>> parser.add_option("--files", action="append", default=['~/.mypkg/defaults'])
>>> opts, args = parser.parse_args(['--files', 'overrides.mypkg'])
>>> opts.files
['~/.... | the default elements will be present in the parsed value for the option, with any values from the command line appended after those default values::
>>> parser.add_option("--files", action="append", default=['~/.mypkg/defaults'])
>>> opts, args = parser.parse_args(['--files', 'overrides.mypkg'])
>>> opts.files
['~/.... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
25ec26d6-ebe1-4d02-ad4a-612022baf5d7 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,226 | supabase-export-v2 | b522d2d67481a232 | option attributes which you may specify to guide :mod:`!optparse`'s behaviour; a few have required attributes, which you must specify for any option using that action.
* ``"store"`` [relevant: :attr:`~Option.type`, :attr:`~Option.dest`,
:attr:`~Option.nargs`, :attr:`~Option.choices`] | trusted_official_docs | CPython Docs | option attributes which you may specify to guide :mod:`!optparse`'s behaviour; a few have required attributes, which you must specify for any option using that action.
* ``"store"`` [relevant: :attr:`~Option.type`, :attr:`~Option.dest`,
:attr:`~Option.nargs`, :attr:`~Option.choices`] | option attributes which you may specify to guide :mod:`!optparse`'s behaviour; a few have required attributes, which you must specify for any option using that action.
* ``"store"`` [relevant: :attr:`~Option.type`, :attr:`~Option.dest`,
:attr:`~Option.nargs`, :attr:`~Option.choices`] | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2b7b16ff-4da2-45ca-b140-9b17d44c5fd9 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,464 | supabase-export-v2 | 4cce948733a58cf1 | parser = OptionParser(option_class=MyOption) parser.add_option("-c", type="complex")
Alternately, you can build your own option list and pass it to OptionParser; if
you don't use :meth:`add_option` in the above way, you don't need to tell
OptionParser which option class to use:: | trusted_official_docs | CPython Docs | parser = OptionParser(option_class=MyOption) parser.add_option("-c", type="complex")
Alternately, you can build your own option list and pass it to OptionParser; if
you don't use :meth:`add_option` in the above way, you don't need to tell
OptionParser which option class to use:: | parser = OptionParser(option_class=MyOption) parser.add_option("-c", type="complex")
Alternately, you can build your own option list and pass it to OptionParser; if
you don't use :meth:`add_option` in the above way, you don't need to tell
OptionParser which option class to use:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2e3214cf-5214-4699-becd-f8d3f7f48b14 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,963 | supabase-export-v2 | c6b5ad7261572c1a | -ffoo --file=foo
Typically, a given option either takes an argument or it doesn't. Lots of
people want an "optional option arguments" feature, meaning that some options
will take an argument if they see it, and won't if they don't. This is
somewhat controversial, because it makes parsing ambiguous: if ``-a`` takes
... | trusted_official_docs | CPython Docs | -ffoo --file=foo
Typically, a given option either takes an argument or it doesn't. Lots of
people want an "optional option arguments" feature, meaning that some options
will take an argument if they see it, and won't if they don't. This is
somewhat controversial, because it makes parsing ambiguous: if ``-a`` takes
... | -ffoo --file=foo
Typically, a given option either takes an argument or it doesn't. Lots of
people want an "optional option arguments" feature, meaning that some options
will take an argument if they see it, and won't if they don't. This is
somewhat controversial, because it makes parsing ambiguous: if ``-a`` takes
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2f20cdfe-f97c-4d1a-a0bc-38a6ecd7d4e6 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,471 | supabase-export-v2 | a7ca718528e6e8fd | a certain type; or rather, a string that can be converted to a certain type. These options require a :attr:`~Option.type` attribute to the Option constructor.
These are overlapping sets: some default "store" actions are ``"store"``,
``"store_const"``, ``"append"``, and ``"count"``, while the default "typed"
actions are... | trusted_official_docs | CPython Docs | a certain type; or rather, a string that can be converted to a certain type. These options require a :attr:`~Option.type` attribute to the Option constructor.
These are overlapping sets: some default "store" actions are ``"store"``,
``"store_const"``, ``"append"``, and ``"count"``, while the default "typed"
actions are... | a certain type; or rather, a string that can be converted to a certain type. These options require a :attr:`~Option.type` attribute to the Option constructor.
These are overlapping sets: some default "store" actions are ``"store"``,
``"store_const"``, ``"append"``, and ``"count"``, while the default "typed"
actions are... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2f7e53f5-c151-42f2-b9b6-3e971666fc41 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,998 | supabase-export-v2 | 240809331ec2698e | * ``args``, the list of positional arguments leftover after parsing options
This tutorial section only covers the four most important option attributes:
:attr:`~Option.action`, :attr:`~Option.type`, :attr:`~Option.dest`
(destination), and :attr:`~Option.help`. Of these, :attr:`~Option.action` is the
most fundamental. | trusted_official_docs | CPython Docs | * ``args``, the list of positional arguments leftover after parsing options
This tutorial section only covers the four most important option attributes:
:attr:`~Option.action`, :attr:`~Option.type`, :attr:`~Option.dest`
(destination), and :attr:`~Option.help`. Of these, :attr:`~Option.action` is the
most fundamental. | * ``args``, the list of positional arguments leftover after parsing options
This tutorial section only covers the four most important option attributes:
:attr:`~Option.action`, :attr:`~Option.type`, :attr:`~Option.dest`
(destination), and :attr:`~Option.help`. Of these, :attr:`~Option.action` is the
most fundamental. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2fe9ce6c-c70b-4739-a419-32e5018a1a9a | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,438 | supabase-export-v2 | 19179eb22ff325b9 | def floatable(str): try: float(str) return True except ValueError: return False
for arg in parser.rargs:
# stop on --foo like options
if arg[:2] == "--" and len(arg) > 2:
break
# stop on -a, but not on -3 or -3.0
if arg[:1] == "-" and len(arg) > 1 and not floatable(arg):
break
value.append(arg) | trusted_official_docs | CPython Docs | def floatable(str): try: float(str) return True except ValueError: return False
for arg in parser.rargs:
# stop on --foo like options
if arg[:2] == "--" and len(arg) > 2:
break
# stop on -a, but not on -3 or -3.0
if arg[:1] == "-" and len(arg) > 1 and not floatable(arg):
break
value.append(arg) | def floatable(str): try: float(str) return True except ValueError: return False
for arg in parser.rargs:
# stop on --foo like options
if arg[:2] == "--" and len(arg) > 2:
break
# stop on -a, but not on -3 or -3.0
if arg[:1] == "-" and len(arg) > 1 and not floatable(arg):
break
value.append(arg) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
32a0c32f-fa36-49a7-9ad0-64b1a0363bda | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,348 | supabase-export-v2 | 48fb1a95287e6b70 | In that case, :mod:`!optparse` removes that option completely, so it doesn't show up in help text or anywhere else. Carrying on with our existing OptionParser::
parser.add_option("--dry-run", ..., help="new dry-run option") | trusted_official_docs | CPython Docs | In that case, :mod:`!optparse` removes that option completely, so it doesn't show up in help text or anywhere else. Carrying on with our existing OptionParser::
parser.add_option("--dry-run", ..., help="new dry-run option") | In that case, :mod:`!optparse` removes that option completely, so it doesn't show up in help text or anywhere else. Carrying on with our existing OptionParser::
parser.add_option("--dry-run", ..., help="new dry-run option") | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
32e61702-4929-49f0-8365-14b99985f604 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,037 | supabase-export-v2 | 14304bf777d51fb9 | Default values ^^^^^^^^^^^^^^
All of the above examples involve setting some variable (the "destination") when
certain command-line options are seen. What happens if those options are never
seen? Since we didn't supply any defaults, they are all set to ``None``. This
is usually fine, but sometimes you want more control... | trusted_official_docs | CPython Docs | Default values ^^^^^^^^^^^^^^
All of the above examples involve setting some variable (the "destination") when
certain command-line options are seen. What happens if those options are never
seen? Since we didn't supply any defaults, they are all set to ``None``. This
is usually fine, but sometimes you want more control... | Default values ^^^^^^^^^^^^^^
All of the above examples involve setting some variable (the "destination") when
certain command-line options are seen. What happens if those options are never
seen? Since we didn't supply any defaults, they are all set to ``None``. This
is usually fine, but sometimes you want more control... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
32f210c9-4f88-4db8-b2a6-e69b2b0011a2 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,421 | supabase-export-v2 | 5ce629d1d570009a | def check_moon(option, opt_str, value, parser): if is_moon_full(): raise OptionValueError("%s option invalid when moon is full" % opt_str) setattr(parser.values, option.dest, 1) ... parser.add_option("--foo", action="callback", callback=check_moon, dest="foo")
(The definition of ``is_moon_full()`` is left as an exercis... | trusted_official_docs | CPython Docs | def check_moon(option, opt_str, value, parser): if is_moon_full(): raise OptionValueError("%s option invalid when moon is full" % opt_str) setattr(parser.values, option.dest, 1) ... parser.add_option("--foo", action="callback", callback=check_moon, dest="foo")
(The definition of ``is_moon_full()`` is left as an exercis... | def check_moon(option, opt_str, value, parser): if is_moon_full(): raise OptionValueError("%s option invalid when moon is full" % opt_str) setattr(parser.values, option.dest, 1) ... parser.add_option("--foo", action="callback", callback=check_moon, dest="foo")
(The definition of ``is_moon_full()`` is left as an exercis... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3534445c-d2c1-4b12-9d22-c2e304c3c062 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,915 | supabase-export-v2 | b755acb3542033b3 | :mod:`argparse` is the recommended choice for implementing command line applications, as it offers the highest level of baseline functionality with the least application level code.
:mod:`getopt` is retained almost entirely for backwards compatibility reasons. However, it also serves a niche use case as a tool for prot... | trusted_official_docs | CPython Docs | :mod:`argparse` is the recommended choice for implementing command line applications, as it offers the highest level of baseline functionality with the least application level code.
:mod:`getopt` is retained almost entirely for backwards compatibility reasons. However, it also serves a niche use case as a tool for prot... | :mod:`argparse` is the recommended choice for implementing command line applications, as it offers the highest level of baseline functionality with the least application level code.
:mod:`getopt` is retained almost entirely for backwards compatibility reasons. However, it also serves a niche use case as a tool for prot... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3759165e-f7cf-4724-b28d-2f66b15fee04 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,472 | supabase-export-v2 | 8531068d43a4018a | These are overlapping sets: some default "store" actions are ``"store"``, ``"store_const"``, ``"append"``, and ``"count"``, while the default "typed" actions are ``"store"``, ``"append"``, and ``"callback"``.
When you add an action, you need to categorize it by listing it in at least one
of the following class attribut... | trusted_official_docs | CPython Docs | These are overlapping sets: some default "store" actions are ``"store"``, ``"store_const"``, ``"append"``, and ``"count"``, while the default "typed" actions are ``"store"``, ``"append"``, and ``"callback"``.
When you add an action, you need to categorize it by listing it in at least one
of the following class attribut... | These are overlapping sets: some default "store" actions are ``"store"``, ``"store_const"``, ``"append"``, and ``"count"``, while the default "typed" actions are ``"store"``, ``"append"``, and ``"callback"``.
When you add an action, you need to categorize it by listing it in at least one
of the following class attribut... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
39696a27-524b-4e70-b10c-56d2adf86c37 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,315 | supabase-export-v2 | c9fa13be1b0c9908 | Querying and manipulating your option parser ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The default behavior of the option parser can be customized slightly, and you
can also poke around your option parser and see what's there. OptionParser
provides several methods to help you out: | trusted_official_docs | CPython Docs | Querying and manipulating your option parser ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The default behavior of the option parser can be customized slightly, and you
can also poke around your option parser and see what's there. OptionParser
provides several methods to help you out: | Querying and manipulating your option parser ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The default behavior of the option parser can be customized slightly, and you
can also poke around your option parser and see what's there. OptionParser
provides several methods to help you out: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3bb6626a-f0fd-4cba-a396-76cd41fbd2e2 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,958 | supabase-export-v2 | 51dfb16c9015787b | * a slash followed by a letter, or a few letters, or a word, e.g. ``/f``, ``/file``
These option syntaxes are not supported by :mod:`!optparse`, and they never
will be. This is deliberate: the first three are non-standard on any
environment, and the last only makes sense if you're exclusively targeting
Windows or ce... | trusted_official_docs | CPython Docs | * a slash followed by a letter, or a few letters, or a word, e.g. ``/f``, ``/file``
These option syntaxes are not supported by :mod:`!optparse`, and they never
will be. This is deliberate: the first three are non-standard on any
environment, and the last only makes sense if you're exclusively targeting
Windows or ce... | * a slash followed by a letter, or a few letters, or a word, e.g. ``/f``, ``/file``
These option syntaxes are not supported by :mod:`!optparse`, and they never
will be. This is deliberate: the first three are non-standard on any
environment, and the last only makes sense if you're exclusively targeting
Windows or ce... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3bfe2ebd-0f56-4133-ada3-6f76c6c6a560 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,196 | supabase-export-v2 | 32bed21fb7f83468 | keyword to the constructor. Normally created with :meth:`OptionParser.add_option` rather than directly, and can be overridden by a custom class via the *option_class* argument to :class:`OptionParser`.
The following option attributes may be passed as keyword arguments to
:meth:`OptionParser.add_option`. If you pass an ... | trusted_official_docs | CPython Docs | keyword to the constructor. Normally created with :meth:`OptionParser.add_option` rather than directly, and can be overridden by a custom class via the *option_class* argument to :class:`OptionParser`.
The following option attributes may be passed as keyword arguments to
:meth:`OptionParser.add_option`. If you pass an ... | keyword to the constructor. Normally created with :meth:`OptionParser.add_option` rather than directly, and can be overridden by a custom class via the *option_class* argument to :class:`OptionParser`.
The following option attributes may be passed as keyword arguments to
:meth:`OptionParser.add_option`. If you pass an ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3cca56cd-3d94-40c8-87b5-caf5db7024bd | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,964 | supabase-export-v2 | 173bcbf29fa0cd98 | takes an optional argument and ``-b`` is another option entirely, how do we interpret ``-ab``? Because of this ambiguity, :mod:`!optparse` does not support this feature.
positional argument
something leftover in the argument list after options have been parsed, i.e. after options and their arguments have been parsed a... | trusted_official_docs | CPython Docs | takes an optional argument and ``-b`` is another option entirely, how do we interpret ``-ab``? Because of this ambiguity, :mod:`!optparse` does not support this feature.
positional argument
something leftover in the argument list after options have been parsed, i.e. after options and their arguments have been parsed a... | takes an optional argument and ``-b`` is another option entirely, how do we interpret ``-ab``? Because of this ambiguity, :mod:`!optparse` does not support this feature.
positional argument
something leftover in the argument list after options have been parsed, i.e. after options and their arguments have been parsed a... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3d10ace3-a2bd-49b1-92d6-5c9ea0ab91ac | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,113 | supabase-export-v2 | dcf14cf161352563 | How :mod:`!optparse` handles errors ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
There are two broad classes of errors that :mod:`!optparse` has to worry about:
programmer errors and user errors. Programmer errors are usually erroneous
calls to :func:`OptionParser.add_option`, e.g. invalid option strings, unknown
option attribu... | trusted_official_docs | CPython Docs | How :mod:`!optparse` handles errors ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
There are two broad classes of errors that :mod:`!optparse` has to worry about:
programmer errors and user errors. Programmer errors are usually erroneous
calls to :func:`OptionParser.add_option`, e.g. invalid option strings, unknown
option attribu... | How :mod:`!optparse` handles errors ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
There are two broad classes of errors that :mod:`!optparse` has to worry about:
programmer errors and user errors. Programmer errors are usually erroneous
calls to :func:`OptionParser.add_option`, e.g. invalid option strings, unknown
option attribu... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3ee3324a-587e-4f74-8371-fc8256de8512 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,369 | supabase-export-v2 | 526c2c36a1cbb2a4 | Option Callbacks ----------------
When :mod:`!optparse`'s built-in actions and types aren't quite enough for your
needs, you have two choices: extend :mod:`!optparse` or define a callback option. Extending :mod:`!optparse` is more general, but overkill for a lot of simple
cases. Quite often a simple callback is all you... | trusted_official_docs | CPython Docs | Option Callbacks ----------------
When :mod:`!optparse`'s built-in actions and types aren't quite enough for your
needs, you have two choices: extend :mod:`!optparse` or define a callback option. Extending :mod:`!optparse` is more general, but overkill for a lot of simple
cases. Quite often a simple callback is all you... | Option Callbacks ----------------
When :mod:`!optparse`'s built-in actions and types aren't quite enough for your
needs, you have two choices: extend :mod:`!optparse` or define a callback option. Extending :mod:`!optparse` is more general, but overkill for a lot of simple
cases. Quite often a simple callback is all you... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3f91a58b-172b-4a16-991b-928e58177451 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,291 | supabase-export-v2 | ad5d1c7872539508 | :mod:`!optparse` has five built-in option types: ``"string"``, ``"int"``, ``"choice"``, ``"float"`` and ``"complex"``. If you need to add new option types, see section :ref:`optparse-extending-optparse`.
Arguments to string options are not checked or converted in any way: the text on
the command line is stored in the d... | trusted_official_docs | CPython Docs | :mod:`!optparse` has five built-in option types: ``"string"``, ``"int"``, ``"choice"``, ``"float"`` and ``"complex"``. If you need to add new option types, see section :ref:`optparse-extending-optparse`.
Arguments to string options are not checked or converted in any way: the text on
the command line is stored in the d... | :mod:`!optparse` has five built-in option types: ``"string"``, ``"int"``, ``"choice"``, ``"float"`` and ``"complex"``. If you need to add new option types, see section :ref:`optparse-extending-optparse`.
Arguments to string options are not checked or converted in any way: the text on
the command line is stored in the d... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
44a8fe52-65ed-43e3-b3a2-07d1a00a8f47 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,140 | supabase-export-v2 | 73c99457de3c2c15 | string, it expands ``%prog`` to ``os.path.basename(sys.argv[0])`` (or to ``prog`` if you passed that keyword argument). To suppress a usage message, pass the special value :const:`optparse.SUPPRESS_USAGE`.
``option_list`` (default: ``[]``)
A list of Option objects to populate the parser with. The options in
``option_... | trusted_official_docs | CPython Docs | string, it expands ``%prog`` to ``os.path.basename(sys.argv[0])`` (or to ``prog`` if you passed that keyword argument). To suppress a usage message, pass the special value :const:`optparse.SUPPRESS_USAGE`.
``option_list`` (default: ``[]``)
A list of Option objects to populate the parser with. The options in
``option_... | string, it expands ``%prog`` to ``os.path.basename(sys.argv[0])`` (or to ``prog`` if you passed that keyword argument). To suppress a usage message, pass the special value :const:`optparse.SUPPRESS_USAGE`.
``option_list`` (default: ``[]``)
A list of Option objects to populate the parser with. The options in
``option_... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
453bb3ed-a02f-4e25-a5a8-aa7736f29703 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,397 | supabase-export-v2 | 70e3a1d1e31f89ea | with ``opt_str`` and ``value`` (if applicable) removed, and only the arguments following them still there. Feel free to modify ``parser.rargs``, e.g. by consuming more arguments.
``parser.values``
the object where option values are by default stored (an instance of
optparse.OptionValues). This lets callbacks use the ... | trusted_official_docs | CPython Docs | with ``opt_str`` and ``value`` (if applicable) removed, and only the arguments following them still there. Feel free to modify ``parser.rargs``, e.g. by consuming more arguments.
``parser.values``
the object where option values are by default stored (an instance of
optparse.OptionValues). This lets callbacks use the ... | with ``opt_str`` and ``value`` (if applicable) removed, and only the arguments following them still there. Feel free to modify ``parser.rargs``, e.g. by consuming more arguments.
``parser.values``
the object where option values are by default stored (an instance of
optparse.OptionValues). This lets callbacks use the ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
45962d16-f493-4b68-bef6-18ec31f181d2 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,462 | supabase-export-v2 | dbb6093841391ac8 | end up modifying the :attr:`~Option.TYPE_CHECKER` attribute of :mod:`!optparse`'s Option class. This being Python, nothing stops you from doing that except good manners and common sense.)
That's it! Now you can write a script that uses the new option type just like
any other :mod:`!optparse`\ -based script, except you ... | trusted_official_docs | CPython Docs | end up modifying the :attr:`~Option.TYPE_CHECKER` attribute of :mod:`!optparse`'s Option class. This being Python, nothing stops you from doing that except good manners and common sense.)
That's it! Now you can write a script that uses the new option type just like
any other :mod:`!optparse`\ -based script, except you ... | end up modifying the :attr:`~Option.TYPE_CHECKER` attribute of :mod:`!optparse`'s Option class. This being Python, nothing stops you from doing that except good manners and common sense.)
That's it! Now you can write a script that uses the new option type just like
any other :mod:`!optparse`\ -based script, except you ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4669c868-8f1d-48c9-9a80-ebbb0de299a7 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,359 | supabase-export-v2 | 82dde7831fa32177 | .. method:: OptionParser.print_usage(file=None)
Print the usage message for the current program (``self.usage``) to *file*
(default stdout). Any occurrence of the string ``%prog`` in ``self.usage``
is replaced with the name of the current program. Does nothing if
``self.usage`` is empty or not defined. | trusted_official_docs | CPython Docs | .. method:: OptionParser.print_usage(file=None)
Print the usage message for the current program (``self.usage``) to *file*
(default stdout). Any occurrence of the string ``%prog`` in ``self.usage``
is replaced with the name of the current program. Does nothing if
``self.usage`` is empty or not defined. | .. method:: OptionParser.print_usage(file=None)
Print the usage message for the current program (``self.usage``) to *file*
(default stdout). Any occurrence of the string ``%prog`` in ``self.usage``
is replaced with the name of the current program. Does nothing if
``self.usage`` is empty or not defined. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
48f21845-edeb-45b5-85be-b0af4085b1a6 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,230 | supabase-export-v2 | dac4a2338ec24bfc | If :attr:`~Option.type` is not supplied, it defaults to ``"string"``.
If :attr:`~Option.dest` is not supplied, :mod:`!optparse` derives a destination
from the first long option string (e.g., ``--foo-bar`` implies
``foo_bar``). If there are no long option strings, :mod:`!optparse` derives a
destination from the first... | trusted_official_docs | CPython Docs | If :attr:`~Option.type` is not supplied, it defaults to ``"string"``.
If :attr:`~Option.dest` is not supplied, :mod:`!optparse` derives a destination
from the first long option string (e.g., ``--foo-bar`` implies
``foo_bar``). If there are no long option strings, :mod:`!optparse` derives a
destination from the first... | If :attr:`~Option.type` is not supplied, it defaults to ``"string"``.
If :attr:`~Option.dest` is not supplied, :mod:`!optparse` derives a destination
from the first long option string (e.g., ``--foo-bar`` implies
``foo_bar``). If there are no long option strings, :mod:`!optparse` derives a
destination from the first... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
496b9804-8f0c-4e13-aad3-0f5db7588eb1 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,056 | supabase-export-v2 | b7f5cd0ddcdc0fe5 | --quiet be vewwy quiet (I'm hunting wabbits) -f FILE, --filename=FILE write output to FILE -m MODE, --mode=MODE interaction mode: novice, intermediate, or expert [default: intermediate]
(If the help output is triggered by a help option, :mod:`!optparse` exits after
printing the help text.) | trusted_official_docs | CPython Docs | --quiet be vewwy quiet (I'm hunting wabbits) -f FILE, --filename=FILE write output to FILE -m MODE, --mode=MODE interaction mode: novice, intermediate, or expert [default: intermediate]
(If the help output is triggered by a help option, :mod:`!optparse` exits after
printing the help text.) | --quiet be vewwy quiet (I'm hunting wabbits) -f FILE, --filename=FILE write output to FILE -m MODE, --mode=MODE interaction mode: novice, intermediate, or expert [default: intermediate]
(If the help output is triggered by a help option, :mod:`!optparse` exits after
printing the help text.) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4a32d1d1-c48e-41c0-8637-49e87085eacf | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,065 | supabase-export-v2 | 504b06e70871fd6d | -m MODE, --mode=MODE
Here, "MODE" is called the meta-variable: it stands for the argument that the
user is expected to supply to ``-m``/``--mode``. By default,
:mod:`!optparse` converts the destination variable name to uppercase and uses
that for the meta-variable. Sometimes, that's not what you want---for
example,... | trusted_official_docs | CPython Docs | -m MODE, --mode=MODE
Here, "MODE" is called the meta-variable: it stands for the argument that the
user is expected to supply to ``-m``/``--mode``. By default,
:mod:`!optparse` converts the destination variable name to uppercase and uses
that for the meta-variable. Sometimes, that's not what you want---for
example,... | -m MODE, --mode=MODE
Here, "MODE" is called the meta-variable: it stands for the argument that the
user is expected to supply to ``-m``/``--mode``. By default,
:mod:`!optparse` converts the destination variable name to uppercase and uses
that for the meta-variable. Sometimes, that's not what you want---for
example,... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4b4d9124-5013-4f68-bf82-0d67ac9f59c9 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,227 | supabase-export-v2 | 8f3e7ae9ee1c20a3 | * ``"store"`` [relevant: :attr:`~Option.type`, :attr:`~Option.dest`, :attr:`~Option.nargs`, :attr:`~Option.choices`]
The option must be followed by an argument, which is converted to a value
according to :attr:`~Option.type` and stored in :attr:`~Option.dest`. If
:attr:`~Option.nargs` > 1, multiple arguments will be ... | trusted_official_docs | CPython Docs | * ``"store"`` [relevant: :attr:`~Option.type`, :attr:`~Option.dest`, :attr:`~Option.nargs`, :attr:`~Option.choices`]
The option must be followed by an argument, which is converted to a value
according to :attr:`~Option.type` and stored in :attr:`~Option.dest`. If
:attr:`~Option.nargs` > 1, multiple arguments will be ... | * ``"store"`` [relevant: :attr:`~Option.type`, :attr:`~Option.dest`, :attr:`~Option.nargs`, :attr:`~Option.choices`]
The option must be followed by an argument, which is converted to a value
according to :attr:`~Option.type` and stored in :attr:`~Option.dest`. If
:attr:`~Option.nargs` > 1, multiple arguments will be ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4b934222-a2c1-4386-b26c-d5b64e4676d2 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,057 | supabase-export-v2 | 7abb9197995e3651 | (If the help output is triggered by a help option, :mod:`!optparse` exits after printing the help text.)
There's a lot going on here to help :mod:`!optparse` generate the best possible
help message: | trusted_official_docs | CPython Docs | (If the help output is triggered by a help option, :mod:`!optparse` exits after printing the help text.)
There's a lot going on here to help :mod:`!optparse` generate the best possible
help message: | (If the help output is triggered by a help option, :mod:`!optparse` exits after printing the help text.)
There's a lot going on here to help :mod:`!optparse` generate the best possible
help message: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4cf87de0-01d0-4fa7-8360-29e5d67d7e3a | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,019 | supabase-export-v2 | 48ad9e85ee4057a5 | parser.add_option("-f", "--file", dest="filename")
If you don't supply a destination, :mod:`!optparse` figures out a sensible
default from the option strings: if the first long option string is
``--foo-bar``, then the default destination is ``foo_bar``. If there are no
long option strings, :mod:`!optparse` looks at the... | trusted_official_docs | CPython Docs | parser.add_option("-f", "--file", dest="filename")
If you don't supply a destination, :mod:`!optparse` figures out a sensible
default from the option strings: if the first long option string is
``--foo-bar``, then the default destination is ``foo_bar``. If there are no
long option strings, :mod:`!optparse` looks at the... | parser.add_option("-f", "--file", dest="filename")
If you don't supply a destination, :mod:`!optparse` figures out a sensible
default from the option strings: if the first long option string is
``--foo-bar``, then the default destination is ``foo_bar``. If there are no
long option strings, :mod:`!optparse` looks at the... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4e341764-0771-45f3-bfdd-5ca158496c14 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,938 | supabase-export-v2 | 212b3ebe71363e28 | <yourscript> --file=outfile -q
As it parses the command line, :mod:`!optparse` sets attributes of the
``options`` object returned by :meth:`~OptionParser.parse_args` based on user-supplied
command-line values. When :meth:`~OptionParser.parse_args` returns from parsing this command
line, ``options.filename`` will be ``"... | trusted_official_docs | CPython Docs | <yourscript> --file=outfile -q
As it parses the command line, :mod:`!optparse` sets attributes of the
``options`` object returned by :meth:`~OptionParser.parse_args` based on user-supplied
command-line values. When :meth:`~OptionParser.parse_args` returns from parsing this command
line, ``options.filename`` will be ``"... | <yourscript> --file=outfile -q
As it parses the command line, :mod:`!optparse` sets attributes of the
``options`` object returned by :meth:`~OptionParser.parse_args` based on user-supplied
command-line values. When :meth:`~OptionParser.parse_args` returns from parsing this command
line, ``options.filename`` will be ``"... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4fdbcdf5-5ddf-42f9-a220-abc2a2ca985e | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,071 | supabase-export-v2 | 9939e10650e3420a | it is convenient to group these options for better help output. An :class:`OptionParser` can contain several option groups, each of which can contain several options.
An option group is obtained using the class :class:`OptionGroup`: | trusted_official_docs | CPython Docs | it is convenient to group these options for better help output. An :class:`OptionParser` can contain several option groups, each of which can contain several options.
An option group is obtained using the class :class:`OptionGroup`: | it is convenient to group these options for better help output. An :class:`OptionParser` can contain several option groups, each of which can contain several options.
An option group is obtained using the class :class:`OptionGroup`: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
52072a7e-52dc-4bf2-bb51-5c2eb0ffc364 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,023 | supabase-export-v2 | 37ccf8531db5461a | Handling boolean (flag) options ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Flag options---set a variable to true or false when a particular option is
seen---are quite common. :mod:`!optparse` supports them with two separate actions,
``store_true`` and ``store_false``. For example, you might have a ``verbose``
flag that is turned ... | trusted_official_docs | CPython Docs | Handling boolean (flag) options ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Flag options---set a variable to true or false when a particular option is
seen---are quite common. :mod:`!optparse` supports them with two separate actions,
``store_true`` and ``store_false``. For example, you might have a ``verbose``
flag that is turned ... | Handling boolean (flag) options ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Flag options---set a variable to true or false when a particular option is
seen---are quite common. :mod:`!optparse` supports them with two separate actions,
``store_true`` and ``store_false``. For example, you might have a ``verbose``
flag that is turned ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5253018e-d1bd-4ee1-a148-363e458dd245 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,452 | supabase-export-v2 | 841256eef00d4cda | def check_mytype(option, opt, value)
where ``option`` is an :class:`Option` instance, ``opt`` is an option string
(e.g., ``-f``), and ``value`` is the string from the command line that must
be checked and converted to your desired type. ``check_mytype()`` should
return an object of the hypothetical type ``mytype``. ... | trusted_official_docs | CPython Docs | def check_mytype(option, opt, value)
where ``option`` is an :class:`Option` instance, ``opt`` is an option string
(e.g., ``-f``), and ``value`` is the string from the command line that must
be checked and converted to your desired type. ``check_mytype()`` should
return an object of the hypothetical type ``mytype``. ... | def check_mytype(option, opt, value)
where ``option`` is an :class:`Option` instance, ``opt`` is an option string
(e.g., ``-f``), and ``value`` is the string from the command line that must
be checked and converted to your desired type. ``check_mytype()`` should
return an object of the hypothetical type ``mytype``. ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
53adbecb-8056-44d9-b7eb-51ef833adbe0 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,987 | supabase-export-v2 | 6fe4940d3803e0b5 | parser.add_option(opt_str, ..., attr=value, ...)
Each option has one or more option strings, such as ``-f`` or ``--file``,
and several option attributes that tell :mod:`!optparse` what to expect and what
to do when it encounters that option on the command line. | trusted_official_docs | CPython Docs | parser.add_option(opt_str, ..., attr=value, ...)
Each option has one or more option strings, such as ``-f`` or ``--file``,
and several option attributes that tell :mod:`!optparse` what to expect and what
to do when it encounters that option on the command line. | parser.add_option(opt_str, ..., attr=value, ...)
Each option has one or more option strings, such as ``-f`` or ``--file``,
and several option attributes that tell :mod:`!optparse` what to expect and what
to do when it encounters that option on the command line. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
55995782-5491-47e7-afd7-e74888873a99 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,363 | supabase-export-v2 | c2917684d7574912 | .. method:: OptionParser.set_defaults(dest=value, ...)
Set default values for several option destinations at once. Using
:meth:`set_defaults` is the preferred way to set default values for options,
since multiple options can share the same destination. For example, if
several "mode" options all set the same destinat... | trusted_official_docs | CPython Docs | .. method:: OptionParser.set_defaults(dest=value, ...)
Set default values for several option destinations at once. Using
:meth:`set_defaults` is the preferred way to set default values for options,
since multiple options can share the same destination. For example, if
several "mode" options all set the same destinat... | .. method:: OptionParser.set_defaults(dest=value, ...)
Set default values for several option destinations at once. Using
:meth:`set_defaults` is the preferred way to set default values for options,
since multiple options can share the same destination. For example, if
several "mode" options all set the same destinat... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
55b8aac8-8e26-4263-ab11-eaae2265fcc5 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,395 | supabase-export-v2 | d95770433ed7cf35 | ``parser`` is the OptionParser instance driving the whole thing, mainly useful because you can access some other interesting data through its instance attributes:
``parser.largs``
the current list of leftover arguments, ie. arguments that have been
consumed but are neither options nor option arguments. Feel free to m... | trusted_official_docs | CPython Docs | ``parser`` is the OptionParser instance driving the whole thing, mainly useful because you can access some other interesting data through its instance attributes:
``parser.largs``
the current list of leftover arguments, ie. arguments that have been
consumed but are neither options nor option arguments. Feel free to m... | ``parser`` is the OptionParser instance driving the whole thing, mainly useful because you can access some other interesting data through its instance attributes:
``parser.largs``
the current list of leftover arguments, ie. arguments that have been
consumed but are neither options nor option arguments. Feel free to m... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5a6ee945-e62f-437b-b4bb-f1330c9a6665 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,298 | supabase-export-v2 | 85e5de4f8b01085d | by calling :func:`int` with the appropriate base (2, 8, 10, or 16). If this fails, so will :mod:`!optparse`, although with a more useful error message.
``"float"`` and ``"complex"`` option arguments are converted directly with
:func:`float` and :func:`complex`, with similar error-handling. | trusted_official_docs | CPython Docs | by calling :func:`int` with the appropriate base (2, 8, 10, or 16). If this fails, so will :mod:`!optparse`, although with a more useful error message.
``"float"`` and ``"complex"`` option arguments are converted directly with
:func:`float` and :func:`complex`, with similar error-handling. | by calling :func:`int` with the appropriate base (2, 8, 10, or 16). If this fails, so will :mod:`!optparse`, although with a more useful error message.
``"float"`` and ``"complex"`` option arguments are converted directly with
:func:`float` and :func:`complex`, with similar error-handling. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5a860385-bae9-4eae-8f59-cd8f6f6946b4 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,927 | supabase-export-v2 | 107170066cc4084e | supplying ``-o=foo`` gives ``output="=foo"`` when using ``optparse``, but gives ``output="foo"`` with ``argparse`` (since ``=`` is special cased as an alternative separator for option parameter values)
Whether these differing behaviors in the ``argparse`` version are
considered desirable or a problem will depend on the... | trusted_official_docs | CPython Docs | supplying ``-o=foo`` gives ``output="=foo"`` when using ``optparse``, but gives ``output="foo"`` with ``argparse`` (since ``=`` is special cased as an alternative separator for option parameter values)
Whether these differing behaviors in the ``argparse`` version are
considered desirable or a problem will depend on the... | supplying ``-o=foo`` gives ``output="=foo"`` when using ``optparse``, but gives ``output="foo"`` with ``argparse`` (since ``=`` is special cased as an alternative separator for option parameter values)
Whether these differing behaviors in the ``argparse`` version are
considered desirable or a problem will depend on the... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5bfb6e4a-f97a-4092-876b-d160b30ef42a | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,287 | supabase-export-v2 | 5cce7d937c6782be | * ``"version"``
Prints the version number supplied to the OptionParser to stdout and exits. The version number is actually formatted and printed by the
``print_version()`` method of OptionParser. Generally only relevant if the
``version`` argument is supplied to the OptionParser constructor. As with
:attr:`~Option.h... | trusted_official_docs | CPython Docs | * ``"version"``
Prints the version number supplied to the OptionParser to stdout and exits. The version number is actually formatted and printed by the
``print_version()`` method of OptionParser. Generally only relevant if the
``version`` argument is supplied to the OptionParser constructor. As with
:attr:`~Option.h... | * ``"version"``
Prints the version number supplied to the OptionParser to stdout and exits. The version number is actually formatted and printed by the
``print_version()`` method of OptionParser. Generally only relevant if the
``version`` argument is supplied to the OptionParser constructor. As with
:attr:`~Option.h... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5d5ef16e-af3e-4906-b79f-4d4187ff1fc2 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,934 | supabase-export-v2 | c3545291d5251443 | Here's an example of using :mod:`!optparse` in a simple script::
from optparse import OptionParser
... parser = OptionParser()
parser.add_option("-f", "--file", dest="filename",
help="write report to FILE", metavar="FILE")
parser.add_option("-q", "--quiet",
action="store_false", dest="verbose", default=True,
help... | trusted_official_docs | CPython Docs | Here's an example of using :mod:`!optparse` in a simple script::
from optparse import OptionParser
... parser = OptionParser()
parser.add_option("-f", "--file", dest="filename",
help="write report to FILE", metavar="FILE")
parser.add_option("-q", "--quiet",
action="store_false", dest="verbose", default=True,
help... | Here's an example of using :mod:`!optparse` in a simple script::
from optparse import OptionParser
... parser = OptionParser()
parser.add_option("-f", "--file", dest="filename",
help="write report to FILE", metavar="FILE")
parser.add_option("-q", "--quiet",
action="store_false", dest="verbose", default=True,
help... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5d69d139-5010-428b-a0cb-2d9f34a32a5e | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,177 | supabase-export-v2 | e18b3dd98e9a0b80 | ``"help"`` print a usage message including all options and the documentation for them
(If you don't supply an action, the default is ``"store"``. For this action,
you may also supply :attr:`~Option.type` and :attr:`~Option.dest` option
attributes; see :ref:`optparse-standard-option-actions`.) | trusted_official_docs | CPython Docs | ``"help"`` print a usage message including all options and the documentation for them
(If you don't supply an action, the default is ``"store"``. For this action,
you may also supply :attr:`~Option.type` and :attr:`~Option.dest` option
attributes; see :ref:`optparse-standard-option-actions`.) | ``"help"`` print a usage message including all options and the documentation for them
(If you don't supply an action, the default is ``"store"``. For this action,
you may also supply :attr:`~Option.type` and :attr:`~Option.dest` option
attributes; see :ref:`optparse-standard-option-actions`.) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5f23c87e-f9db-4779-b767-b76e894dae1a | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,929 | supabase-export-v2 | e30dedd7fbc1aa7e | .. seealso::
:pypi:`click` is a third party argument processing library (originally
based on ``optparse``), which allows command line applications to be
developed as a set of decorated command implementation functions. | trusted_official_docs | CPython Docs | .. seealso::
:pypi:`click` is a third party argument processing library (originally
based on ``optparse``), which allows command line applications to be
developed as a set of decorated command implementation functions. | .. seealso::
:pypi:`click` is a third party argument processing library (originally
based on ``optparse``), which allows command line applications to be
developed as a set of decorated command implementation functions. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5f8c1672-194e-4866-9483-1069291a1ff9 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,955 | supabase-export-v2 | 77466165a53fef21 | * a hyphen followed by a few letters, e.g. ``-pf`` (this is *not* the same as multiple options merged into a single argument)
* a hyphen followed by a whole word, e.g. ``-file`` (this is technically
equivalent to the previous syntax, but they aren't usually seen in the same
program) | trusted_official_docs | CPython Docs | * a hyphen followed by a few letters, e.g. ``-pf`` (this is *not* the same as multiple options merged into a single argument)
* a hyphen followed by a whole word, e.g. ``-file`` (this is technically
equivalent to the previous syntax, but they aren't usually seen in the same
program) | * a hyphen followed by a few letters, e.g. ``-pf`` (this is *not* the same as multiple options merged into a single argument)
* a hyphen followed by a whole word, e.g. ``-file`` (this is technically
equivalent to the previous syntax, but they aren't usually seen in the same
program) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
609dfe08-33c0-415d-ae31-f041f828b30c | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,151 | supabase-export-v2 | d48fe8aa878f661e | Populating the parser ^^^^^^^^^^^^^^^^^^^^^
There are several ways to populate the parser with options. The preferred way
is by using :meth:`OptionParser.add_option`, as shown in section
:ref:`optparse-tutorial`. :meth:`add_option` can be called in one of two ways: | trusted_official_docs | CPython Docs | Populating the parser ^^^^^^^^^^^^^^^^^^^^^
There are several ways to populate the parser with options. The preferred way
is by using :meth:`OptionParser.add_option`, as shown in section
:ref:`optparse-tutorial`. :meth:`add_option` can be called in one of two ways: | Populating the parser ^^^^^^^^^^^^^^^^^^^^^
There are several ways to populate the parser with options. The preferred way
is by using :meth:`OptionParser.add_option`, as shown in section
:ref:`optparse-tutorial`. :meth:`add_option` can be called in one of two ways: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
60b92cbf-7646-414e-83fd-a13c72429ce3 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,453 | supabase-export-v2 | 5f66ebf4c58f4025 | returned by a type-checking function will wind up in the OptionValues instance returned by :meth:`OptionParser.parse_args`, or be passed to a callback as the ``value`` parameter.
Your type-checking function should raise :exc:`OptionValueError` if it
encounters any problems. :exc:`OptionValueError` takes a single strin... | trusted_official_docs | CPython Docs | returned by a type-checking function will wind up in the OptionValues instance returned by :meth:`OptionParser.parse_args`, or be passed to a callback as the ``value`` parameter.
Your type-checking function should raise :exc:`OptionValueError` if it
encounters any problems. :exc:`OptionValueError` takes a single strin... | returned by a type-checking function will wind up in the OptionValues instance returned by :meth:`OptionParser.parse_args`, or be passed to a callback as the ``value`` parameter.
Your type-checking function should raise :exc:`OptionValueError` if it
encounters any problems. :exc:`OptionValueError` takes a single strin... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
619273ef-85f8-4b40-a994-9443605b1818 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,153 | supabase-export-v2 | e4ab8153c5591178 | * pass it an Option instance (as returned by :func:`make_option`)
* pass it any combination of positional and keyword arguments that are
acceptable to :func:`make_option` (i.e., to the Option constructor), and it
will create the Option instance for you | trusted_official_docs | CPython Docs | * pass it an Option instance (as returned by :func:`make_option`)
* pass it any combination of positional and keyword arguments that are
acceptable to :func:`make_option` (i.e., to the Option constructor), and it
will create the Option instance for you | * pass it an Option instance (as returned by :func:`make_option`)
* pass it any combination of positional and keyword arguments that are
acceptable to :func:`make_option` (i.e., to the Option constructor), and it
will create the Option instance for you | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
62b85cda-194e-4a4e-951a-c38bd617d315 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,990 | supabase-export-v2 | 13fa3e88391039a1 | parser.add_option("-f", "--file", ...)
You're free to define as many short option strings and as many long option
strings as you like (including zero), as long as there is at least one option
string overall. | trusted_official_docs | CPython Docs | parser.add_option("-f", "--file", ...)
You're free to define as many short option strings and as many long option
strings as you like (including zero), as long as there is at least one option
string overall. | parser.add_option("-f", "--file", ...)
You're free to define as many short option strings and as many long option
strings as you like (including zero), as long as there is at least one option
string overall. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
63ee308d-529a-4695-b9cb-28921c3232cf | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,375 | supabase-export-v2 | 9bff967410515c84 | Defining a callback option ^^^^^^^^^^^^^^^^^^^^^^^^^^
As always, the easiest way to define a callback option is by using the
:meth:`OptionParser.add_option` method. Apart from :attr:`~Option.action`, the
only option attribute you must specify is ``callback``, the function to call:: | trusted_official_docs | CPython Docs | Defining a callback option ^^^^^^^^^^^^^^^^^^^^^^^^^^
As always, the easiest way to define a callback option is by using the
:meth:`OptionParser.add_option` method. Apart from :attr:`~Option.action`, the
only option attribute you must specify is ``callback``, the function to call:: | Defining a callback option ^^^^^^^^^^^^^^^^^^^^^^^^^^
As always, the easiest way to define a callback option is by using the
:meth:`OptionParser.add_option` method. Apart from :attr:`~Option.action`, the
only option attribute you must specify is ``callback``, the function to call:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
64f61914-755c-4463-9610-e773b097188d | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,281 | supabase-export-v2 | ec004bda49622298 | # usually, a help option is added automatically, but that can # be suppressed using the add_help_option argument parser = OptionParser(add_help_option=False)
parser.add_option("-h", "--help", action="help")
parser.add_option("-v", action="store_true", dest="verbose",
help="Be moderately verbose")
parser.add_option("... | trusted_official_docs | CPython Docs | # usually, a help option is added automatically, but that can # be suppressed using the add_help_option argument parser = OptionParser(add_help_option=False)
parser.add_option("-h", "--help", action="help")
parser.add_option("-v", action="store_true", dest="verbose",
help="Be moderately verbose")
parser.add_option("... | # usually, a help option is added automatically, but that can # be suppressed using the add_help_option argument parser = OptionParser(add_help_option=False)
parser.add_option("-h", "--help", action="help")
parser.add_option("-v", action="store_true", dest="verbose",
help="Be moderately verbose")
parser.add_option("... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
652682a6-6e38-4df1-8a01-7b1165b85b17 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,076 | supabase-export-v2 | c5c88b21f19c166b | :class:`OptionGroup` inherits from :class:`OptionContainer` (like :class:`OptionParser`) and so the :meth:`add_option` method can be used to add an option to the group.
Once all the options are declared, using the :class:`OptionParser` method
:meth:`add_option_group` the group is added to the previously defined parser. | trusted_official_docs | CPython Docs | :class:`OptionGroup` inherits from :class:`OptionContainer` (like :class:`OptionParser`) and so the :meth:`add_option` method can be used to add an option to the group.
Once all the options are declared, using the :class:`OptionParser` method
:meth:`add_option_group` the group is added to the previously defined parser. | :class:`OptionGroup` inherits from :class:`OptionContainer` (like :class:`OptionParser`) and so the :meth:`add_option` method can be used to add an option to the group.
Once all the options are declared, using the :class:`OptionParser` method
:meth:`add_option_group` the group is added to the previously defined parser. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
65b51df5-011c-4c9d-bcf8-97805d4a632a | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,917 | supabase-export-v2 | 6eb5346ec6af8380 | :mod:`!optparse` should be considered as an alternative to :mod:`argparse` in the following cases:
* an application is already using :mod:`!optparse` and doesn't want to risk the
subtle behavioural changes that may arise when migrating to :mod:`argparse`
* the application requires additional control over the way optio... | trusted_official_docs | CPython Docs | :mod:`!optparse` should be considered as an alternative to :mod:`argparse` in the following cases:
* an application is already using :mod:`!optparse` and doesn't want to risk the
subtle behavioural changes that may arise when migrating to :mod:`argparse`
* the application requires additional control over the way optio... | :mod:`!optparse` should be considered as an alternative to :mod:`argparse` in the following cases:
* an application is already using :mod:`!optparse` and doesn't want to risk the
subtle behavioural changes that may arise when migrating to :mod:`argparse`
* the application requires additional control over the way optio... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
65cc5054-9deb-4047-a1df-6fdbb8081598 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,925 | supabase-export-v2 | 35bbd9ca068e7da1 | application after the option processing is complete. In the ``argparse`` version, positional arguments are declared and processed in the same way as the named options.
However, the ``argparse`` version will also handle some parameter combination
differently from the way the ``optparse`` version would handle them. For e... | trusted_official_docs | CPython Docs | application after the option processing is complete. In the ``argparse`` version, positional arguments are declared and processed in the same way as the named options.
However, the ``argparse`` version will also handle some parameter combination
differently from the way the ``optparse`` version would handle them. For e... | application after the option processing is complete. In the ``argparse`` version, positional arguments are declared and processed in the same way as the named options.
However, the ``argparse`` version will also handle some parameter combination
differently from the way the ``optparse`` version would handle them. For e... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
66e04e65-081e-4e57-a131-1c2c9e16b6e9 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,345 | supabase-export-v2 | 491b6e478fe32cb6 | parser = OptionParser(conflict_handler="resolve") parser.add_option("-n", "--dry-run", ..., help="do no harm") parser.add_option("-n", "--noisy", ..., help="be noisy")
At this point, :mod:`!optparse` detects that a previously added option is already
using the ``-n`` option string. Since ``conflict_handler`` is ``"resol... | trusted_official_docs | CPython Docs | parser = OptionParser(conflict_handler="resolve") parser.add_option("-n", "--dry-run", ..., help="do no harm") parser.add_option("-n", "--noisy", ..., help="be noisy")
At this point, :mod:`!optparse` detects that a previously added option is already
using the ``-n`` option string. Since ``conflict_handler`` is ``"resol... | parser = OptionParser(conflict_handler="resolve") parser.add_option("-n", "--dry-run", ..., help="do no harm") parser.add_option("-n", "--noisy", ..., help="be noisy")
At this point, :mod:`!optparse` detects that a previously added option is already
using the ``-n`` option string. Since ``conflict_handler`` is ``"resol... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
685c04ca-3998-472b-b3c8-a5c535535d6c | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,068 | supabase-export-v2 | 7f63b5ee75042af9 | "write output to FILE". This is a simple but effective way to make your help text a lot clearer and more useful for end users.
* options that have a default value can include ``%default`` in the help
string---\ :mod:`!optparse` will replace it with :func:`str` of the option's
default value. If an option has no defaul... | trusted_official_docs | CPython Docs | "write output to FILE". This is a simple but effective way to make your help text a lot clearer and more useful for end users.
* options that have a default value can include ``%default`` in the help
string---\ :mod:`!optparse` will replace it with :func:`str` of the option's
default value. If an option has no defaul... | "write output to FILE". This is a simple but effective way to make your help text a lot clearer and more useful for end users.
* options that have a default value can include ``%default`` in the help
string---\ :mod:`!optparse` will replace it with :func:`str` of the option's
default value. If an option has no defaul... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
68abcdc1-443f-43d3-9064-c45158291d1f | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,088 | supabase-export-v2 | 5cfbb742488b4cfa | = OptionGroup(parser, "Debug Options") group.add_option("-d", "--debug", action="store_true", help="Print debug information") group.add_option("-s", "--sql", action="store_true", help="Print all SQL statements executed") group.add_option("-e", action="store_true", help="Print every action done") parser.add_option_group... | trusted_official_docs | CPython Docs | = OptionGroup(parser, "Debug Options") group.add_option("-d", "--debug", action="store_true", help="Print debug information") group.add_option("-s", "--sql", action="store_true", help="Print all SQL statements executed") group.add_option("-e", action="store_true", help="Print every action done") parser.add_option_group... | = OptionGroup(parser, "Debug Options") group.add_option("-d", "--debug", action="store_true", help="Print debug information") group.add_option("-s", "--sql", action="store_true", help="Print all SQL statements executed") group.add_option("-e", action="store_true", help="Print every action done") parser.add_option_group... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
69bfd4a2-cb2a-483c-9d16-bfddd6430248 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,431 | supabase-export-v2 | b7921d06f0257723 | of conventional Unix command-line parsing that :mod:`!optparse` normally handles for you. In particular, callbacks should implement the conventional rules for bare ``--`` and ``-`` arguments:
* either ``--`` or ``-`` can be option arguments | trusted_official_docs | CPython Docs | of conventional Unix command-line parsing that :mod:`!optparse` normally handles for you. In particular, callbacks should implement the conventional rules for bare ``--`` and ``-`` arguments:
* either ``--`` or ``-`` can be option arguments | of conventional Unix command-line parsing that :mod:`!optparse` normally handles for you. In particular, callbacks should implement the conventional rules for bare ``--`` and ``-`` arguments:
* either ``--`` or ``-`` can be option arguments | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6a3bf196-fea6-4ac4-be30-01460f25c553 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,959 | supabase-export-v2 | 6e0407db2ce1b292 | first three are non-standard on any environment, and the last only makes sense if you're exclusively targeting Windows or certain legacy platforms (e.g. VMS, MS-DOS).
option argument
an argument that follows an option, is closely associated with that option,
and is consumed from the argument list when that option is.... | trusted_official_docs | CPython Docs | first three are non-standard on any environment, and the last only makes sense if you're exclusively targeting Windows or certain legacy platforms (e.g. VMS, MS-DOS).
option argument
an argument that follows an option, is closely associated with that option,
and is consumed from the argument list when that option is.... | first three are non-standard on any environment, and the last only makes sense if you're exclusively targeting Windows or certain legacy platforms (e.g. VMS, MS-DOS).
option argument
an argument that follows an option, is closely associated with that option,
and is consumed from the argument list when that option is.... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6b2081eb-bd0a-436c-a1c5-41b1c00c14f4 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,041 | supabase-export-v2 | 3ce58ddc3d6711c1 | values apply to the *destination* rather than to any particular option, and these two options happen to have the same destination, this is exactly equivalent::
parser.add_option("-v", action="store_true", dest="verbose")
parser.add_option("-q", action="store_false", dest="verbose", default=True) | trusted_official_docs | CPython Docs | values apply to the *destination* rather than to any particular option, and these two options happen to have the same destination, this is exactly equivalent::
parser.add_option("-v", action="store_true", dest="verbose")
parser.add_option("-q", action="store_false", dest="verbose", default=True) | values apply to the *destination* rather than to any particular option, and these two options happen to have the same destination, this is exactly equivalent::
parser.add_option("-v", action="store_true", dest="verbose")
parser.add_option("-q", action="store_false", dest="verbose", default=True) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6b7a644d-f336-48b1-a800-ee02f1e17af4 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,015 | supabase-export-v2 | 2509573efc8b2bf2 | time, we'll jam the option argument right up against the option: since ``-n42`` (one argument) is equivalent to ``-n 42`` (two arguments), the code ::
(options, args) = parser.parse_args(["-n42"])
print(options.num) | trusted_official_docs | CPython Docs | time, we'll jam the option argument right up against the option: since ``-n42`` (one argument) is equivalent to ``-n 42`` (two arguments), the code ::
(options, args) = parser.parse_args(["-n42"])
print(options.num) | time, we'll jam the option argument right up against the option: since ``-n42`` (one argument) is equivalent to ``-n 42`` (two arguments), the code ::
(options, args) = parser.parse_args(["-n42"])
print(options.num) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6bf8654e-3c77-40bd-9442-d03045105e8a | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,142 | supabase-export-v2 | 22551b4f9fcca482 | ``option_class`` (default: optparse.Option) Class to use when adding options to the parser in :meth:`add_option`.
``version`` (default: ``None``)
A version string to print when the user supplies a version option. If you
supply a true value for ``version``, :mod:`!optparse` automatically adds a
version option with th... | trusted_official_docs | CPython Docs | ``option_class`` (default: optparse.Option) Class to use when adding options to the parser in :meth:`add_option`.
``version`` (default: ``None``)
A version string to print when the user supplies a version option. If you
supply a true value for ``version``, :mod:`!optparse` automatically adds a
version option with th... | ``option_class`` (default: optparse.Option) Class to use when adding options to the parser in :meth:`add_option`.
``version`` (default: ``None``)
A version string to print when the user supplies a version option. If you
supply a true value for ``version``, :mod:`!optparse` automatically adds a
version option with th... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6c7dc405-aba8-444b-8bb4-57cb0b6c03e9 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,277 | supabase-export-v2 | a5e56311ea7f9ef0 | string is supplied for an option, it will still be listed in the help message. To omit an option entirely, use the special value :const:`optparse.SUPPRESS_HELP`.
:mod:`!optparse` automatically adds a :attr:`~Option.help` option to all
OptionParsers, so you do not normally need to create one. | trusted_official_docs | CPython Docs | string is supplied for an option, it will still be listed in the help message. To omit an option entirely, use the special value :const:`optparse.SUPPRESS_HELP`.
:mod:`!optparse` automatically adds a :attr:`~Option.help` option to all
OptionParsers, so you do not normally need to create one. | string is supplied for an option, it will still be listed in the help message. To omit an option entirely, use the special value :const:`optparse.SUPPRESS_HELP`.
:mod:`!optparse` automatically adds a :attr:`~Option.help` option to all
OptionParsers, so you do not normally need to create one. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6ce8c7d7-f24d-4d3d-a1f2-e0cb0b4ee84c | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,282 | supabase-export-v2 | ba5035e0ef21f28c | parser.add_option("-h", "--help", action="help") parser.add_option("-v", action="store_true", dest="verbose", help="Be moderately verbose") parser.add_option("--file", dest="filename", help="Input file to read data from") parser.add_option("--secret", help=SUPPRESS_HELP)
If :mod:`!optparse` sees either ``-h`` or ``--he... | trusted_official_docs | CPython Docs | parser.add_option("-h", "--help", action="help") parser.add_option("-v", action="store_true", dest="verbose", help="Be moderately verbose") parser.add_option("--file", dest="filename", help="Input file to read data from") parser.add_option("--secret", help=SUPPRESS_HELP)
If :mod:`!optparse` sees either ``-h`` or ``--he... | parser.add_option("-h", "--help", action="help") parser.add_option("-v", action="store_true", dest="verbose", help="Be moderately verbose") parser.add_option("--file", dest="filename", help="Input file to read data from") parser.add_option("--secret", help=SUPPRESS_HELP)
If :mod:`!optparse` sees either ``-h`` or ``--he... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6e4c53d4-89a7-4fa0-ae7a-604b8cae26a6 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 48,933 | supabase-export-v2 | 950f72b59c5f8b09 | and parse the command line. :mod:`!optparse` allows users to specify options in the conventional GNU/POSIX syntax, and additionally generates usage and help messages for you.
Here's an example of using :mod:`!optparse` in a simple script:: | trusted_official_docs | CPython Docs | and parse the command line. :mod:`!optparse` allows users to specify options in the conventional GNU/POSIX syntax, and additionally generates usage and help messages for you.
Here's an example of using :mod:`!optparse` in a simple script:: | and parse the command line. :mod:`!optparse` allows users to specify options in the conventional GNU/POSIX syntax, and additionally generates usage and help messages for you.
Here's an example of using :mod:`!optparse` in a simple script:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6e9bc359-50f5-46a4-965a-0db1c27881af | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,079 | supabase-export-v2 | 99da075b2f362c38 | OptionGroup(parser, "Dangerous Options", "Caution: use these options at your own risk. " "It is believed that some of them bite.") group.add_option("-g", action="store_true", help="Group option.") parser.add_option_group(group)
This would result in the following help output: | trusted_official_docs | CPython Docs | OptionGroup(parser, "Dangerous Options", "Caution: use these options at your own risk. " "It is believed that some of them bite.") group.add_option("-g", action="store_true", help="Group option.") parser.add_option_group(group)
This would result in the following help output: | OptionGroup(parser, "Dangerous Options", "Caution: use these options at your own risk. " "It is believed that some of them bite.") group.add_option("-g", action="store_true", help="Group option.") parser.add_option_group(group)
This would result in the following help output: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6f3b9ad4-c8b8-4d76-9b95-c5a0159fa11f | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,138 | supabase-export-v2 | c52c98075cc850a7 | .. class:: OptionParser(...)
The OptionParser constructor has no required arguments, but a number of
optional keyword arguments. You should always pass them as keyword
arguments, i.e. do not rely on the order in which the arguments are declared. | trusted_official_docs | CPython Docs | .. class:: OptionParser(...)
The OptionParser constructor has no required arguments, but a number of
optional keyword arguments. You should always pass them as keyword
arguments, i.e. do not rely on the order in which the arguments are declared. | .. class:: OptionParser(...)
The OptionParser constructor has no required arguments, but a number of
optional keyword arguments. You should always pass them as keyword
arguments, i.e. do not rely on the order in which the arguments are declared. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
706364b7-e1d1-435a-b0d8-aa286b36c753 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,379 | supabase-export-v2 | c2161c91e88ad042 | to your callback, and it will only pass additional arguments if you specify them via :attr:`~Option.callback_args` and :attr:`~Option.callback_kwargs`. Thus, the minimal callback function signature is::
def my_callback(option, opt, value, parser): | trusted_official_docs | CPython Docs | to your callback, and it will only pass additional arguments if you specify them via :attr:`~Option.callback_args` and :attr:`~Option.callback_kwargs`. Thus, the minimal callback function signature is::
def my_callback(option, opt, value, parser): | to your callback, and it will only pass additional arguments if you specify them via :attr:`~Option.callback_args` and :attr:`~Option.callback_kwargs`. Thus, the minimal callback function signature is::
def my_callback(option, opt, value, parser): | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
710749ff-eebe-4fb8-88e3-a8267774af9f | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,011 | supabase-export-v2 | ccfd5fba7c6d617d | sees the option string ``-f``, it consumes the next argument, ``foo.txt``, and stores it in ``options.filename``. So, after this call to :meth:`~OptionParser.parse_args`, ``options.filename`` is ``"foo.txt"``.
Some other option types supported by :mod:`!optparse` are ``int`` and ``float``. Here's an option that expects... | trusted_official_docs | CPython Docs | sees the option string ``-f``, it consumes the next argument, ``foo.txt``, and stores it in ``options.filename``. So, after this call to :meth:`~OptionParser.parse_args`, ``options.filename`` is ``"foo.txt"``.
Some other option types supported by :mod:`!optparse` are ``int`` and ``float``. Here's an option that expects... | sees the option string ``-f``, it consumes the next argument, ``foo.txt``, and stores it in ``options.filename``. So, after this call to :meth:`~OptionParser.parse_args`, ``options.filename`` is ``"foo.txt"``.
Some other option types supported by :mod:`!optparse` are ``int`` and ``float``. Here's an option that expects... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
75a3104b-7362-4030-9b5d-3a96f7a3b47d | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,062 | supabase-export-v2 | 5276b1a17b4ed6a0 | supply a usage string, :mod:`!optparse` uses a bland but sensible default: ``"Usage: %prog [options]"``, which is fine if your script doesn't take any positional arguments.
* every option defines a help string, and doesn't worry about
line-wrapping---\ :mod:`!optparse` takes care of wrapping lines and making
the help... | trusted_official_docs | CPython Docs | supply a usage string, :mod:`!optparse` uses a bland but sensible default: ``"Usage: %prog [options]"``, which is fine if your script doesn't take any positional arguments.
* every option defines a help string, and doesn't worry about
line-wrapping---\ :mod:`!optparse` takes care of wrapping lines and making
the help... | supply a usage string, :mod:`!optparse` uses a bland but sensible default: ``"Usage: %prog [options]"``, which is fine if your script doesn't take any positional arguments.
* every option defines a help string, and doesn't worry about
line-wrapping---\ :mod:`!optparse` takes care of wrapping lines and making
the help... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
76998598-fc7d-44c3-836e-15c346d48b2f | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,344 | supabase-export-v2 | a9e138dac470a32a | As an example, let's define an :class:`OptionParser` that resolves conflicts intelligently and add conflicting options to it::
parser = OptionParser(conflict_handler="resolve")
parser.add_option("-n", "--dry-run", ..., help="do no harm")
parser.add_option("-n", "--noisy", ..., help="be noisy") | trusted_official_docs | CPython Docs | As an example, let's define an :class:`OptionParser` that resolves conflicts intelligently and add conflicting options to it::
parser = OptionParser(conflict_handler="resolve")
parser.add_option("-n", "--dry-run", ..., help="do no harm")
parser.add_option("-n", "--noisy", ..., help="be noisy") | As an example, let's define an :class:`OptionParser` that resolves conflicts intelligently and add conflicting options to it::
parser = OptionParser(conflict_handler="resolve")
parser.add_option("-n", "--dry-run", ..., help="do no harm")
parser.add_option("-n", "--noisy", ..., help="be noisy") | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7925c934-461e-4930-99f7-93b2f560c99e | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,470 | supabase-export-v2 | 83e97c0282fef832 | :mod:`!optparse` storing a value to an attribute of the current OptionValues instance; these options require a :attr:`~Option.dest` attribute to be supplied to the Option constructor.
"typed" actions
actions that take a value from the command line and expect it to be of a
certain type; or rather, a string that can be... | trusted_official_docs | CPython Docs | :mod:`!optparse` storing a value to an attribute of the current OptionValues instance; these options require a :attr:`~Option.dest` attribute to be supplied to the Option constructor.
"typed" actions
actions that take a value from the command line and expect it to be of a
certain type; or rather, a string that can be... | :mod:`!optparse` storing a value to an attribute of the current OptionValues instance; these options require a :attr:`~Option.dest` attribute to be supplied to the Option constructor.
"typed" actions
actions that take a value from the command line and expect it to be of a
certain type; or rather, a string that can be... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7963dab3-93f1-4bce-bd98-a3c562f56469 | CPython Docs | file://datasets/cpython/Doc/library/optparse.rst | unknown | fb35db8d-6782-49dd-8f4e-89244d3635e0 | 49,494 | supabase-export-v2 | a5f91671e0318a54 | * :meth:`MyOption.take_action` implements just this one new action, and passes control back to :meth:`Option.take_action` for the standard :mod:`!optparse` actions.
* ``values`` is an instance of the optparse_parser.Values class, which provides
the very useful :meth:`ensure_value` method. :meth:`ensure_value` is
esse... | trusted_official_docs | CPython Docs | * :meth:`MyOption.take_action` implements just this one new action, and passes control back to :meth:`Option.take_action` for the standard :mod:`!optparse` actions.
* ``values`` is an instance of the optparse_parser.Values class, which provides
the very useful :meth:`ensure_value` method. :meth:`ensure_value` is
esse... | * :meth:`MyOption.take_action` implements just this one new action, and passes control back to :meth:`Option.take_action` for the standard :mod:`!optparse` actions.
* ``values`` is an instance of the optparse_parser.Values class, which provides
the very useful :meth:`ensure_value` method. :meth:`ensure_value` is
esse... | python, official-docs, cpython, P0 | Local_Trusted_Corpus |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.