|
10 | 10 |
|
11 | 11 | **Source code:** :source:`Lib/optparse.py` |
12 | 12 |
|
13 | | -.. deprecated:: 3.2 |
14 | | - The :mod:`optparse` module is :term:`soft deprecated` and will not be |
15 | | - developed further; development will continue with the :mod:`argparse` |
16 | | - module. |
| 13 | +.. note:: |
| 14 | + |
| 15 | + :mod:`argparse` (rather than this module) is the recommended standard |
| 16 | + library module for implementing command line applications unless one |
| 17 | + of the following caveats applies: |
| 18 | + |
| 19 | + * the application requires additional control over the way options and |
| 20 | + positional parameters are interleaved on the command line (including |
| 21 | + the ability to disable the interleaving feature completely) |
| 22 | + * the application requires additional control over the incremental parsing |
| 23 | + of command line elements (while ``argparse`` does support this, the |
| 24 | + exact way it will work in practice is sometimes unpredictable) |
| 25 | + * the application requires additional control over the handling of options |
| 26 | + which accept parameter values that may start with ``-`` (such as delegated |
| 27 | + options to be passed to invoked subprocesses). |
| 28 | + |
| 29 | + These ``argparse`` caveats also mean that :mod:`optparse` is likely to |
| 30 | + provide a better foundation for library authors *writing* third party |
| 31 | + command line argument processing libraries. |
| 32 | + |
| 33 | +.. seealso:: |
| 34 | + |
| 35 | + The :pypi:`"click" package <click>` is an ``optparse`` based third party |
| 36 | + argument processing library which allows command line applications to be |
| 37 | + developed as a set of appropriately decorated command implementation |
| 38 | + functions. |
| 39 | + |
| 40 | +.. seealso:: |
| 41 | + |
| 42 | + The :pypi:`"Typer" package <click>` is a ``click`` based third party |
| 43 | + argument processing library which allows the use of annotated Python |
| 44 | + type hints to define an application's command line interface. |
17 | 45 |
|
18 | 46 | -------------- |
19 | 47 |
|
|
0 commit comments