diff options
author | R David Murray <rdmurray@bitdance.com> | 2012-09-08 20:47:24 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2012-09-08 20:47:24 (GMT) |
commit | b9495c78a16c9fc0ddf55caa88f5eeda959da002 (patch) | |
tree | cd5fb521e85ea79cfde37faf49ef8ce754d0ce29 | |
parent | 1b6e7c47f2b9f02c90423684376591a1c9f5c0cc (diff) | |
download | cpython-b9495c78a16c9fc0ddf55caa88f5eeda959da002.zip cpython-b9495c78a16c9fc0ddf55caa88f5eeda959da002.tar.gz cpython-b9495c78a16c9fc0ddf55caa88f5eeda959da002.tar.bz2 |
closes #5088: document behavior of optparse defaults with 'append' action.
-rw-r--r-- | Doc/library/optparse.rst | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Doc/library/optparse.rst b/Doc/library/optparse.rst index d0783e7..c14b790 100644 --- a/Doc/library/optparse.rst +++ b/Doc/library/optparse.rst @@ -1168,6 +1168,17 @@ must specify for any option using that action. options.tracks.append(int("4")) + The ``append`` action calls the ``append`` method on the current value of the + option. This means that any default value specified must have an ``append`` + method. It also means that if the default value is non-empty, the default + elements will be present in the parsed value for the option, with any values + from the command line appended after those default values:: + + >>> parser.add_option("--files", action="append", default=['~/.mypkg/defaults']) + >>> opts, args = parser.parse_args(['--files', 'overrides.mypkg']) + >>> opts.files + ['~/.mypkg/defaults', 'overrides.mypkg'] + * ``"append_const"`` [required: :attr:`~Option.const`; relevant: :attr:`~Option.dest`] |