Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > [ANN] argparse 0.3 - Command-line parsing library

Thread Tools

[ANN] argparse 0.3 - Command-line parsing library

Steven Bethard
Posts: n/a
Announcing argparse 0.3

argparse home:

argparse single module download:

argparse bundled downloads at PyPI:

About this release

This release moves argparse's development status from Pre-Alpha to
Alpha. The API is basically stable, though reasonable change requests
will still be considered.

New in this release

* The '--' pseudo-argument can now be used to terminate the arg list
of an optional::

>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('-x', nargs='+')
>>> parser.add_argument('y')
>>> parser.parse_args('-x X1 X2 X3 -- Y'.split())

Namespace(x=['X1', 'X2', 'X3'], y='Y')

About argparse

The argparse module is an optparse-inspired command line parser that
improves on optparse by:

* handling both optional and positional arguments
* supporting parsers that dispatch to sub-parsers
* producing more informative usage messages
* supporting actions that consume any number of command-line args
* allowing types and actions to be specified with simple callables
instead of hacking class attributes like STORE_ACTIONS or

as well as including a number of other more minor improvements on the
optparse API. To whet your appetite, here's a simple program that sums
its command-line arguments and writes them to a file::

parser = argparse.ArgumentParser()
parser.add_argument('integers', type=int, nargs='+')
parser.add_argument('--log', type='outfile', default=sys.stdout)
args = parser.parse_args()
args.log.write('%s\n' % sum(args.integers))
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[ANN] argparse 0.6 - Command-line parsing library Steven Bethard Python 0 02-24-2007 06:11 PM
[ANN] argparse 0.5 - Command-line parsing library Steven Bethard Python 0 01-17-2007 02:22 AM
[ANN] argparse 0.4 - Command-line parsing library Steven Bethard Python 0 01-05-2007 12:45 AM
[ANN] argparse 0.2 - Command-line parsing library Steven Bethard Python 0 10-24-2006 04:13 PM
[ANN] argparse 0.1 - Command-line parsing library Steven Bethard Python 1 10-10-2006 11:06 PM