]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-21018: added missing documentation about escaping characters for configparser...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 10 Sep 2019 13:32:42 +0000 (06:32 -0700)
committerJulien Palard <julien@palard.fr>
Tue, 10 Sep 2019 13:32:42 +0000 (15:32 +0200)
Document how $ and % can be escaped in configparser.
(cherry picked from commit 9a94093189417adddd6b59d6c80cc5544630c8aa)

Co-authored-by: Arun Persaud <arun@nubati.net>
Doc/library/configparser.rst

index 68b663ff7f65e54b1d06b9fc96c689af3dcf8d1d..6ab858578ba24235bf9d81bb254e42d76ef6b899 100644 (file)
@@ -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