diff options
author | Éric Araujo <merwok@netwok.org> | 2011-07-29 15:59:17 (GMT) |
---|---|---|
committer | Éric Araujo <merwok@netwok.org> | 2011-07-29 15:59:17 (GMT) |
commit | 63b18a4445a22d157b5ddf0677cc904356d83d81 (patch) | |
tree | f979990c24c45f8a6b589225cc3ae2c2309cb9fd /Doc/library/argparse.rst | |
parent | e801aa2a1d291635b3607bc424c639a992799254 (diff) | |
download | cpython-63b18a4445a22d157b5ddf0677cc904356d83d81.zip cpython-63b18a4445a22d157b5ddf0677cc904356d83d81.tar.gz cpython-63b18a4445a22d157b5ddf0677cc904356d83d81.tar.bz2 |
Add a link target for argparse.Namespace (#8982)
Diffstat (limited to 'Doc/library/argparse.rst')
-rw-r--r-- | Doc/library/argparse.rst | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 61e1786..3db8fec 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -110,7 +110,7 @@ Parsing arguments :class:`ArgumentParser` parses args through the :meth:`~ArgumentParser.parse_args` method. This will inspect the command line, convert each arg to the appropriate type and then invoke the appropriate action. -In most cases, this means a simple namespace object will be built up from +In most cases, this means a simple :class:`Namespace` object will be built up from attributes parsed out of the command line:: >>> parser.parse_args(['--sum', '7', '-1', '42']) @@ -722,7 +722,7 @@ the Action API. The easiest way to do this is to extend * ``parser`` - The ArgumentParser object which contains this action. -* ``namespace`` - The namespace object that will be returned by +* ``namespace`` - The :class:`Namespace` object that will be returned by :meth:`~ArgumentParser.parse_args`. Most actions add an attribute to this object. @@ -1333,11 +1333,14 @@ interactive prompt:: The Namespace object ^^^^^^^^^^^^^^^^^^^^ -By default, :meth:`~ArgumentParser.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`:: +.. class:: Namespace + + Simple class used by default by :meth:`~ArgumentParser.parse_args` to create + an object holding attributes and return it. + +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, :func:`vars`:: >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo') |