FAQ
Announcing argparse 0.7
-----------------------

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

* positional arguments
* sub-commands
* required options
* options with a variable number of args
* better usage messages
* a much simpler extension mechanism

and a number of other improvements on the optparse API.

Download argparse
=================

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 adds support for single-dash long options and combining
single-dash options in a single option string.

Note that the 'outfile' type is still deprecated and will likely be
removed in the next release. Please update your code to use the new
FileType factory.

New in this release
===================

* Single-dash long options (e.g. ``-foo`` or ``-foo-bar``)

* Combining single-dash options (e.g. ``-xy`` is now the same as
``-x -y`` when ``-x`` does not take an argument)

Example argparse code
=====================

Here's a simple program that sums its command-line arguments and
writes them to a file::

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

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedMar 25, '07 at 5:05p
activeMar 25, '07 at 5:05p
posts1
users1
websitepython.org

1 user in discussion

Steven Bethard: 1 post

People

Translate

site design / logo © 2022 Grokbase