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
d09a05eb
Kaydet (Commit)
d09a05eb
authored
Eyl 25, 2012
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge 3.2 except the massive Misc/NEWS conflict, so hand apply the NEWS entry.
üst
dbe50887
1dedd0a4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
argparse.rst
Doc/library/argparse.rst
+14
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/argparse.rst
Dosyayı görüntüle @
d09a05eb
...
...
@@ -923,6 +923,17 @@ was not present at the command line::
>>> parser.parse_args(''.split())
Namespace(foo=42)
If the ``default`` value is a string, the parser parses the value as if it
were a command-line argument. In particular, the parser applies any type_
conversion argument, if provided, before setting the attribute on the
:class:`Namespace` return value. Otherwise, the parser uses the value as is::
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('--length', default='10', type=int)
>>> parser.add_argument('--width', default=10.5, type=int)
>>> parser.parse_args()
Namespace(length=10, width=10.5)
For positional arguments with nargs_ equal to ``?`` or ``*``, the ``default`` value
is used when no command-line argument was present::
...
...
@@ -961,6 +972,9 @@ types and functions can be used directly as the value of the ``type`` argument::
>>> parser.parse_args('2 temp.txt'.split())
Namespace(bar=<_io.TextIOWrapper name='temp.txt' encoding='UTF-8'>, foo=2)
See the section on the default_ keyword argument for information on when the
``type`` argument is applied to default arguments.
To ease the use of various types of files, the argparse module provides the
factory FileType which takes the ``mode=`` and ``bufsize=`` arguments of the
:func:`open` function. For example, ``FileType('w')`` can be used to create a
...
...
Misc/NEWS
Dosyayı görüntüle @
d09a05eb
...
...
@@ -99,6 +99,9 @@ Build
Documentation
-------------
- Issue #15935: Clarification of argparse docs, re: add_argument() type and
default arguments. Patch contributed by Chris Jerdonek.
- Issue #11964: Document a change in v3.2 to the behavior of the indent
parameter of json encoding operations.
...
...
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