[Python-checkins] bpo-21018: added missing documentation about escaping characters for configparser (GH-6137) (GH-15846)

Julien Palard webhook-mailer at python.org
Tue Sep 10 09:33:00 EDT 2019


https://github.com/python/cpython/commit/5cf8155bbd2c65572295b26e96c221763b3322f0
commit: 5cf8155bbd2c65572295b26e96c221763b3322f0
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Julien Palard <julien at palard.fr>
date: 2019-09-10T15:32:56+02:00
summary:

bpo-21018: added missing documentation about escaping characters for configparser (GH-6137) (GH-15846)

Document how $ and % can be escaped in configparser.
(cherry picked from commit 9a94093189417adddd6b59d6c80cc5544630c8aa)

Co-authored-by: Arun Persaud <arun at nubati.net>

files:
M Doc/library/configparser.rst

diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst
index 04b52dc7b215..739477f55fdd 100644
--- a/Doc/library/configparser.rst
+++ b/Doc/library/configparser.rst
@@ -313,6 +313,8 @@ from ``get()`` calls.
       my_dir: %(home_dir)s/lumberjack
       my_pictures: %(my_dir)s/Pictures
 
+      [Escape]
+      gain: 80%%  # use a %% to escape the % sign (% is the only character that needs to be escaped)
 
    In the example above, :class:`ConfigParser` with *interpolation* set to
    ``BasicInterpolation()`` would resolve ``%(home_dir)s`` to the value of
@@ -346,6 +348,9 @@ from ``get()`` calls.
       my_dir: ${home_dir}/lumberjack
       my_pictures: ${my_dir}/Pictures
 
+      [Escape]
+      cost: $$80  # use a $$ to escape the $ sign ($ is the only character that needs to be escaped)
+
    Values from other sections can be fetched as well:
 
    .. code-block:: ini



More information about the Python-checkins mailing list