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
3f69a059
Kaydet (Commit)
3f69a059
authored
Mar 26, 2011
tarafından
Steven Bethard
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #8982: Improve the documentation for the argparse Namespace object. (Merge from 3.2.)
üst
53958629
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
7 deletions
+20
-7
argparse.rst
Doc/library/argparse.rst
+16
-5
NEWS
Misc/NEWS
+4
-2
No files found.
Doc/library/argparse.rst
Dosyayı görüntüle @
3f69a059
...
@@ -1310,13 +1310,24 @@ of :data:`sys.argv`. This can be accomplished by passing a list of strings to
...
@@ -1310,13 +1310,24 @@ of :data:`sys.argv`. This can be accomplished by passing a list of strings to
Namespace(accumulate=<built-in function sum>, integers=[1, 2, 3, 4])
Namespace(accumulate=<built-in function sum>, 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`::
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('--foo')
>>> args = parser.parse_args(['--foo', 'BAR'])
>>> vars(args)
{'foo': 'BAR'}
It may also be useful to have an :class:`ArgumentParser` assign attributes to an
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
already existing object, rather than a new :class:`Namespace` object. This can
that is normally used. This can be achieved by specifying the ``namespace=``
be achieved by specifying the ``namespace=`` keyword argument::
keyword argument::
>>> class C(object):
>>> class C(object):
... pass
... pass
...
...
Misc/NEWS
Dosyayı görüntüle @
3f69a059
...
@@ -235,6 +235,10 @@ Library
...
@@ -235,6 +235,10 @@ Library
- Issue #9509: argparse now properly handles IOErrors raised by
- Issue #9509: argparse now properly handles IOErrors raised by
argparse.FileType.
argparse.FileType.
- Issue #9348: Raise an early error if argparse nargs and metavar don'
t
match
.
-
Issue
#
8982
:
Improve
the
documentation
for
the
argparse
Namespace
object
.
Extension
Modules
Extension
Modules
-----------------
-----------------
...
@@ -1343,8 +1347,6 @@ Library
...
@@ -1343,8 +1347,6 @@ Library
-
Issue
#
8374
:
Update
the
internal
alias
table
in
the
:
mod
:`
locale
`
module
to
-
Issue
#
8374
:
Update
the
internal
alias
table
in
the
:
mod
:`
locale
`
module
to
cover
recent
locale
changes
and
additions
.
cover
recent
locale
changes
and
additions
.
- Issue #9348: Raise an early error if argparse nargs and metavar don'
t
match
.
Extension
Modules
Extension
Modules
-----------------
-----------------
...
...
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