Upgrading optparse code

Originally, theargparse module had attempted to maintain compatibilitywithoptparse. However,optparse was difficult to extendtransparently, particularly with the changes required to supportnargs= specifiers and better usage messages. When most everything inoptparse had either been copy-pasted over or monkey-patched, it nolonger seemed practical to try to maintain the backwards compatibility.

Theargparse module improves on theoptparsemodule in a number of ways including:

  • Handling positional arguments.

  • Supporting subcommands.

  • Allowing alternative option prefixes like+ and/.

  • Handling zero-or-more and one-or-more style arguments.

  • Producing more informative usage messages.

  • Providing a much simpler interface for customtype andaction.

A partial upgrade path fromoptparse toargparse: