cpython: 423b50086b67 (original) (raw)
Mercurial > cpython
changeset 68977:423b50086b67 3.2
Issue #8982: Improve the documentation for the argparse Namespace object. [#8982]
Steven Bethard steven.bethard@gmail.com | |
---|---|
date | Sat, 26 Mar 2011 19:50:06 +0100 |
parents | 4390d6939a56 |
children | d832756a82d9 72f6f5a29e7a |
files | Doc/library/argparse.rst Misc/NEWS |
diffstat | 2 files changed, 18 insertions(+), 5 deletions(-)[+] [-] Doc/library/argparse.rst 21 Misc/NEWS 2 |
line wrap: on
line diff
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -1314,13 +1314,24 @@ of :data:sys.argv
. This can be accomp
Namespace(accumulate=, integers=[1, 2, 3, 4])
-Custom namespaces
-^^^^^^^^^^^^^^^^^
+The Namespace object
+^^^^^^^^^^^^^^^^^^^^
+
+By default, :meth:parse_args
will return a new object of type :class:Namespace
+where the necessary attributes have been set. This class is deliberately simple,
+just an :class:object
subclass with a readable string representation. If you
+prefer to have dict-like view of the attributes, you can use the standard Python
+idiom via :func:vars
::
+
It may also be useful to have an :class:ArgumentParser
assign attributes to an
-already existing object, rather than the newly-created :class:Namespace
object
-that is normally used. This can be achieved by specifying the namespace=
-keyword argument::
+already existing object, rather than a new :class:Namespace
object. This can
+be achieved by specifying the namespace=
keyword argument::
>>> class C:
... pass