Fix full-stop whitespace in configparser docs
This commit is contained in:
parent
45759a3924
commit
34cea14f74
|
@ -144,12 +144,13 @@ datatypes, you should convert on your own:
|
|||
>>> float(topsecret['CompressionLevel'])
|
||||
9.0
|
||||
|
||||
Extracting Boolean values is not that simple, though. Passing the value
|
||||
to ``bool()`` would do no good since ``bool('False')`` is still
|
||||
``True``. This is why config parsers also provide :meth:`getboolean`.
|
||||
This method is case-insensitive and recognizes Boolean values from
|
||||
``'yes'``/``'no'``, ``'on'``/``'off'`` and ``'1'``/``'0'`` [1]_.
|
||||
For example:
|
||||
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
|
||||
interesting because simply passing the value to ``bool()`` would do no good
|
||||
since ``bool('False')`` is still ``True``. This is why config parsers also
|
||||
provide :meth:`getboolean`. This method is case-insensitive and recognizes
|
||||
Boolean values from ``'yes'``/``'no'``, ``'on'``/``'off'``,
|
||||
``'true'``/``'false'`` and ``'1'``/``'0'`` [1]_. For example:
|
||||
|
||||
.. doctest::
|
||||
|
||||
|
@ -321,9 +322,9 @@ from ``get()`` calls.
|
|||
An alternative handler for interpolation which implements a more advanced
|
||||
syntax, used for instance in ``zc.buildout``. Extended interpolation is
|
||||
using ``${section:option}`` to denote a value from a foreign section.
|
||||
Interpolation can span multiple levels. For convenience, if the ``section:``
|
||||
part is omitted, interpolation defaults to the current section (and possibly
|
||||
the default values from the special section).
|
||||
Interpolation can span multiple levels. For convenience, if the
|
||||
``section:`` part is omitted, interpolation defaults to the current section
|
||||
(and possibly the default values from the special section).
|
||||
|
||||
For example, the configuration specified above with basic interpolation,
|
||||
would look like this with extended interpolation:
|
||||
|
@ -541,9 +542,9 @@ the :meth:`__init__` options:
|
|||
|
||||
* *delimiters*, default value: ``('=', ':')``
|
||||
|
||||
Delimiters are substrings that delimit keys from values within a section. The
|
||||
first occurrence of a delimiting substring on a line is considered a delimiter.
|
||||
This means values (but not keys) can contain the delimiters.
|
||||
Delimiters are substrings that delimit keys from values within a section.
|
||||
The first occurrence of a delimiting substring on a line is considered
|
||||
a delimiter. This means values (but not keys) can contain the delimiters.
|
||||
|
||||
See also the *space_around_delimiters* argument to
|
||||
:meth:`ConfigParser.write`.
|
||||
|
@ -554,10 +555,10 @@ the :meth:`__init__` options:
|
|||
|
||||
Comment prefixes are strings that indicate the start of a valid comment within
|
||||
a config file. *comment_prefixes* are used only on otherwise empty lines
|
||||
(optionally indented) whereas *inline_comment_prefixes* can be used after
|
||||
every valid value (e.g. section names, options and empty lines as well). By
|
||||
default inline comments are disabled and ``'#'`` and ``';'`` are used as
|
||||
prefixes for whole line comments.
|
||||
(optionally indented) whereas *inline_comment_prefixes* can be used
|
||||
after every valid value (e.g. section names, options and empty lines
|
||||
as well). By default inline comments are disabled and ``'#'`` and
|
||||
``';'`` are used as prefixes for whole line comments.
|
||||
|
||||
.. versionchanged:: 3.2
|
||||
In previous versions of :mod:`configparser` behaviour matched
|
||||
|
@ -565,10 +566,10 @@ the :meth:`__init__` options:
|
|||
|
||||
Please note that config parsers don't support escaping of comment prefixes so
|
||||
using *inline_comment_prefixes* may prevent users from specifying option
|
||||
values with characters used as comment prefixes. When in doubt, avoid setting
|
||||
*inline_comment_prefixes*. In any circumstances, the only way of storing
|
||||
comment prefix characters at the beginning of a line in multiline values is to
|
||||
interpolate the prefix, for example::
|
||||
values with characters used as comment prefixes. When in doubt, avoid
|
||||
setting *inline_comment_prefixes*. In any circumstances, the only way of
|
||||
storing comment prefix characters at the beginning of a line in multiline
|
||||
values is to interpolate the prefix, for example::
|
||||
|
||||
>>> from configparser import ConfigParser, ExtendedInterpolation
|
||||
>>> parser = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
|
@ -651,8 +652,8 @@ the :meth:`__init__` options:
|
|||
letting users create complex declarative configurations. This section is
|
||||
normally called ``"DEFAULT"`` but this can be customized to point to any
|
||||
other valid section name. Some typical values include: ``"general"`` or
|
||||
``"common"``. The name provided is used for recognizing default sections when
|
||||
reading from any source and is used when writing configuration back to
|
||||
``"common"``. The name provided is used for recognizing default sections
|
||||
when reading from any source and is used when writing configuration back to
|
||||
a file. Its current value can be retrieved using the
|
||||
``parser_instance.default_section`` attribute and may be modified at runtime
|
||||
(i.e. to convert files from one format to another).
|
||||
|
@ -728,9 +729,10 @@ may be overridden by subclasses or by attribute assignment.
|
|||
.. attribute:: SECTCRE
|
||||
|
||||
A compiled regular expression used to parse section headers. The default
|
||||
matches ``[section]`` to the name ``"section"``. Whitespace is considered part
|
||||
of the section name, thus ``[ larch ]`` will be read as a section of name
|
||||
``" larch "``. Override this attribute if that's unsuitable. For example:
|
||||
matches ``[section]`` to the name ``"section"``. Whitespace is considered
|
||||
part of the section name, thus ``[ larch ]`` will be read as a section of
|
||||
name ``" larch "``. Override this attribute if that's unsuitable. For
|
||||
example:
|
||||
|
||||
.. doctest::
|
||||
|
||||
|
@ -871,8 +873,8 @@ ConfigParser Objects
|
|||
When *delimiters* is given, it is used as the set of substrings that
|
||||
divide keys from values. When *comment_prefixes* is given, it will be used
|
||||
as the set of substrings that prefix comments in otherwise empty lines.
|
||||
Comments can be indented. When *inline_comment_prefixes* is given, it will be
|
||||
used as the set of substrings that prefix comments in non-empty lines.
|
||||
Comments can be indented. When *inline_comment_prefixes* is given, it will
|
||||
be used as the set of substrings that prefix comments in non-empty lines.
|
||||
|
||||
When *strict* is ``True`` (the default), the parser won't allow for
|
||||
any section or option duplicates while reading from a single source (file,
|
||||
|
|
Loading…
Reference in New Issue