[ANN] argparse 0.3 - Command-line parsing library

S

Steven Bethard

Announcing argparse 0.3
-----------------------

argparse home:
http://argparse.python-hosting.com/

argparse single module download:
http://argparse.python-hosting.com/file/trunk/argparse.py?format=raw

argparse bundled downloads at PyPI:
http://www.python.org/pypi/argparse/

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::
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
CHECK_METHODS

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))
args.log.close()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top