cpython (2.7): Add a link target for argparse.Namespace (#8982)

http://hg.python.org/cpython/rev/01722022f88d changeset: 71606:01722022f88d branch: 2.7 parent: 71599:68df566cbf92 user: Éric Araujo <merwok@netwok.org> date: Fri Jul 29 17:59:17 2011 +0200 summary: Add a link target for argparse.Namespace (#8982) files: Doc/library/argparse.rst | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -106,7 +106,7 @@ :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']) @@ -714,7 +714,7 @@ * ``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. @@ -1325,11 +1325,14 @@ 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') -- Repository URL: http://hg.python.org/cpython
participants (1)
-
eric.araujo