diff options
author | steven.bethard <devnull@localhost> | 2010-02-28 06:49:22 +0000 |
---|---|---|
committer | steven.bethard <devnull@localhost> | 2010-02-28 06:49:22 +0000 |
commit | 22948d838fa22c160682419b4be9be7f421c5e39 (patch) | |
tree | f268ce5ee874bd0b2ba2c72adc2a9a9cfd82ef41 /doc/source/add_argument.rst | |
parent | 368317de60c7dcf7c080593270c3fb5a5af1a5ba (diff) | |
download | argparse-22948d838fa22c160682419b4be9be7f421c5e39.tar.gz |
Deprecate ArgumentParser(..., version=XXX, ...) as well as format_version() and print_version(). These should be replaced with .add_argument(..., action='version', ...).
Diffstat (limited to 'doc/source/add_argument.rst')
-rw-r--r-- | doc/source/add_argument.rst | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/doc/source/add_argument.rst b/doc/source/add_argument.rst index e72df5b..374d742 100644 --- a/doc/source/add_argument.rst +++ b/doc/source/add_argument.rst @@ -85,12 +85,12 @@ action >>> parser.parse_args('--str --int'.split()) Namespace(types=[<type 'str'>, <type 'int'>]) -* ``'version'`` - This expects a ``version=`` keyword argument in the :meth:`add_argument` call, and prints version information and exits when invoked. This can be used when the default :class:`ArgumentParser` version flags ``-v, --version`` are not appropriate for your program. +* ``'version'`` - This expects a ``version=`` keyword argument in the :meth:`add_argument` call, and prints version information and exits when invoked. >>> import argparse >>> parser = argparse.ArgumentParser(prog='PROG') - >>> parser.add_argument('-V', action='version', version='%(prog)s 2.0') - >>> parser.parse_args(['-V']) + >>> parser.add_argument('-v', '--version', action='version', version='%(prog)s 2.0') + >>> parser.parse_args(['-v']) PROG 2.0 You can also specify an arbitrary action by passing an object that implements the Action API. The easiest way to do this is to extend ``argparse.Action``, supplying an appropriate ``__call__`` method. The ``__call__`` method accepts four parameters: |