Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
63b18a44
Commit
63b18a44
authored
Jul 29, 2011
by
Éric Araujo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a link target for argparse.Namespace (#8982)
parent
e801aa2a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
Doc/library/argparse.rst
Doc/library/argparse.rst
+10
-7
No files found.
Doc/library/argparse.rst
View file @
63b18a44
...
...
@@ -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')
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment