Differences between revisions 2 and 5 (spanning 3 versions)
Revision 2 as of 2008-11-15 14:01:18
Size: 76
Editor: localhost
Comment: converted to 1.6 markup
Revision 5 as of 2013-03-18 17:49:13
Size: 1314
Editor: techtonik
Comment: the goals of option parsing and description of current solutions
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
OptParse, [[getopt]], ConfigParser,
... fancy_getopt (?), [[gflags]], ...
## The content of this page is in Public Domain

Overview of Python modules for option parsing:

 * [[http://docs.python.org/2/library/getopt.html|getopt]] - procedural interface in stdlib for refugees from the C camp
 * [[OptParse|optparse]] - stdlib name for Optik, a revolutionary API for option parsing in Python 2.x
 * [[http://docs.python.org/3/library/argparse.html|argparse]] - `optparse` pumped up for Python 3.x (and included in Python 2.7)


External tools:

 * [[gflags]] - Google's remedy for C++ refugees
 * [[http://code.google.com/p/py-command-line-options | cmdopts]] - ...
 * [[http://docopt.org/|docopt]] - no API calls needed, it's awesome!

=== The goal of option parsing ===

The option parsing goal can be split in two parts:

  1. identifying the command user needs to execute
  2. changing configuration for the program

For the first part, it will be good if option parsing library could handle 'subcommands'. It is known that 'argparse' can do this and 'optparse' cannot. 'docopt' probably handles this transparently.

For the second thing there should be some strategy to choose how (and which) options are merged into configuration to make the process of program configuration easy for the user and occasional patch contributors.

See also ConfigParser.

Overview of Python modules for option parsing:

  • getopt - procedural interface in stdlib for refugees from the C camp

  • optparse - stdlib name for Optik, a revolutionary API for option parsing in Python 2.x

  • argparse - optparse pumped up for Python 3.x (and included in Python 2.7)

External tools:

  • gflags - Google's remedy for C++ refugees

  • cmdopts - ...

  • docopt - no API calls needed, it's awesome!

1. The goal of option parsing

The option parsing goal can be split in two parts:

  1. identifying the command user needs to execute
  2. changing configuration for the program

For the first part, it will be good if option parsing library could handle 'subcommands'. It is known that 'argparse' can do this and 'optparse' cannot. 'docopt' probably handles this transparently.

For the second thing there should be some strategy to choose how (and which) options are merged into configuration to make the process of program configuration easy for the user and occasional patch contributors.

See also ConfigParser.

OptionParsing (last edited 2021-02-07 21:56:17 by IwanAucamp)

Unable to edit the page? See the FrontPage for instructions.