Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
f0d44bcc
Kaydet (Commit)
f0d44bcc
authored
Tem 29, 2011
tarafından
Éric Araujo
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add a link target for argparse.Namespace (#8982)
üst
9a528306
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
argparse.rst
Doc/library/argparse.rst
+10
-7
No files found.
Doc/library/argparse.rst
Dosyayı görüntüle @
f0d44bcc
...
@@ -106,7 +106,7 @@ Parsing arguments
...
@@ -106,7 +106,7 @@ Parsing arguments
:class:`ArgumentParser` parses args through the
:class:`ArgumentParser` parses args through the
:meth:`~ArgumentParser.parse_args` method. This will inspect the command line,
:meth:`~ArgumentParser.parse_args` method. This will inspect the command line,
convert each arg to the appropriate type and then invoke the appropriate action.
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::
attributes parsed out of the command line::
>>> parser.parse_args(['--sum', '7', '-1', '42'])
>>> parser.parse_args(['--sum', '7', '-1', '42'])
...
@@ -714,7 +714,7 @@ the Action API. The easiest way to do this is to extend
...
@@ -714,7 +714,7 @@ the Action API. The easiest way to do this is to extend
* ``parser`` - The ArgumentParser object which contains this action.
* ``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
:meth:`~ArgumentParser.parse_args`. Most actions add an attribute to this
object.
object.
...
@@ -1325,11 +1325,14 @@ interactive prompt::
...
@@ -1325,11 +1325,14 @@ interactive prompt::
The Namespace object
The Namespace object
^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^
By default, :meth:`~ArgumentParser.parse_args` will return a new object of type
.. class:: Namespace
:class:`Namespace` where the necessary attributes have been set. This class is
deliberately simple, just an :class:`object` subclass with a readable string
Simple class used by default by :meth:`~ArgumentParser.parse_args` to create
representation. If you prefer to have dict-like view of the attributes, you
an object holding attributes and return it.
can use the standard Python idiom via :func:`vars`::
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 = argparse.ArgumentParser()
>>> parser.add_argument('--foo')
>>> 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