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
647680ec
Kaydet (Commit)
647680ec
authored
Eyl 19, 2016
tarafından
Jesus Cea
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Docs: Correctly link to the methods
üst
57bda335
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
19 deletions
+22
-19
configparser.rst
Doc/library/configparser.rst
+22
-19
No files found.
Doc/library/configparser.rst
Dosyayı görüntüle @
647680ec
...
@@ -150,8 +150,8 @@ Since this task is so common, config parsers provide a range of handy getter
...
@@ -150,8 +150,8 @@ Since this task is so common, config parsers provide a range of handy getter
methods to handle integers, floats and booleans. The last one is the most
methods to handle integers, floats and booleans. The last one is the most
interesting because simply passing the value to ``bool()`` would do no good
interesting because simply passing the value to ``bool()`` would do no good
since ``bool('False')`` is still ``True``. This is why config parsers also
since ``bool('False')`` is still ``True``. This is why config parsers also
provide :meth:`
getboolean`. This method is case-insensitive and recognizes
provide :meth:`
~ConfigParser.getboolean`. This method is case-insensitive and
Boolean values from ``'yes'``/``'no'``, ``'on'``/``'off'``,
recognizes
Boolean values from ``'yes'``/``'no'``, ``'on'``/``'off'``,
``'true'``/``'false'`` and ``'1'``/``'0'`` [1]_. For example:
``'true'``/``'false'`` and ``'1'``/``'0'`` [1]_. For example:
.. doctest::
.. doctest::
...
@@ -163,8 +163,9 @@ Boolean values from ``'yes'``/``'no'``, ``'on'``/``'off'``,
...
@@ -163,8 +163,9 @@ Boolean values from ``'yes'``/``'no'``, ``'on'``/``'off'``,
>>> config.getboolean('bitbucket.org', 'Compression')
>>> config.getboolean('bitbucket.org', 'Compression')
True
True
Apart from :meth:`getboolean`, config parsers also provide equivalent
Apart from :meth:`~ConfigParser.getboolean`, config parsers also
:meth:`getint` and :meth:`getfloat` methods. You can register your own
provide equivalent :meth:`~ConfigParser.getint` and
:meth:`~ConfigParser.getfloat` methods. You can register your own
converters and customize the provided ones. [1]_
converters and customize the provided ones. [1]_
Fallback Values
Fallback Values
...
@@ -205,8 +206,9 @@ the ``fallback`` keyword-only argument:
...
@@ -205,8 +206,9 @@ the ``fallback`` keyword-only argument:
... fallback='No such things as monsters')
... fallback='No such things as monsters')
'No such things as monsters'
'No such things as monsters'
The same ``fallback`` argument can be used with the :meth:`getint`,
The same ``fallback`` argument can be used with the
:meth:`getfloat` and :meth:`getboolean` methods, for example:
:meth:`~ConfigParser.getint`, :meth:`~ConfigParser.getfloat` and
:meth:`~ConfigParser.getboolean` methods, for example:
.. doctest::
.. doctest::
...
@@ -670,14 +672,15 @@ the :meth:`__init__` options:
...
@@ -670,14 +672,15 @@ the :meth:`__init__` options:
* *converters*, default value: not set
* *converters*, default value: not set
Config parsers provide option value getters that perform type conversion. By
Config parsers provide option value getters that perform type conversion. By
default :meth:`getint`, :meth:`getfloat`, and :meth:`getboolean` are
default :meth:`~ConfigParser.getint`, :meth:`~ConfigParser.getfloat`, and
implemented. Should other getters be desirable, users may define them in
:meth:`~ConfigParser.getboolean` are implemented. Should other getters be
a subclass or pass a dictionary where each key is a name of the converter and
desirable, users may define them in a subclass or pass a dictionary where each
each value is a callable implementing said conversion. For instance, passing
key is a name of the converter and each value is a callable implementing said
``{'decimal': decimal.Decimal}`` would add :meth:`getdecimal` on both the
conversion. For instance, passing ``{'decimal': decimal.Decimal}`` would add
parser object and all section proxies. In other words, it will be possible
:meth:`getdecimal` on both the parser object and all section proxies. In
to write both ``parser_instance.getdecimal('section', 'key', fallback=0)``
other words, it will be possible to write both
and ``parser_instance['section'].getdecimal('key', 0)``.
``parser_instance.getdecimal('section', 'key', fallback=0)`` and
``parser_instance['section'].getdecimal('key', 0)``.
If the converter needs to access the state of the parser, it can be
If the converter needs to access the state of the parser, it can be
implemented as a method on a config parser subclass. If the name of this
implemented as a method on a config parser subclass. If the name of this
...
@@ -690,11 +693,11 @@ be overridden by subclasses or by attribute assignment.
...
@@ -690,11 +693,11 @@ be overridden by subclasses or by attribute assignment.
.. attribute:: BOOLEAN_STATES
.. attribute:: BOOLEAN_STATES
By default when using :meth:`
getboolean`, config parsers consider the
By default when using :meth:`
~ConfigParser.getboolean`, config parsers
following values ``True``: ``'1'``, ``'yes'``, ``'true'``, ``'on'`` and the
consider the following values ``True``: ``'1'``, ``'yes'``, ``'true'``,
following values ``False``: ``'0'``, ``'no'``, ``'false'``, ``'off'``. You
``'on'`` and the following values ``False``: ``'0'``, ``'no'``, ``'false'``,
can override this by specifying a custom dictionary of strings and their
``'off'``. You can override this by specifying a custom dictionary of strings
Boolean outcomes. For example:
and their
Boolean outcomes. For example:
.. doctest::
.. doctest::
...
...
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