As of python 2.7
, optparse
is deprecated, and will hopefully go away in the future.
argparse
is better for all the reasons listed on its original page (https://code.google.com/archive/p/argparse/):
- handling positional arguments
- supporting sub-commands
- 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 custom types and actions
More information is also in PEP 389, which is the vehicle by which argparse
made it into the standard library.