summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2010-11-06 13:22:13 (GMT)
committerEric Smith <eric@trueblade.com>2010-11-06 13:22:13 (GMT)
commit5ad85f81b0664fafcd936b1dbfb728a3ace8f7a2 (patch)
treecddac9173305e0f2355200cd6e5ccad6b659630d /Doc
parent7322fcf84bdd516983588cc64b1e7166c62d9e12 (diff)
downloadcpython-5ad85f81b0664fafcd936b1dbfb728a3ace8f7a2.zip
cpython-5ad85f81b0664fafcd936b1dbfb728a3ace8f7a2.tar.gz
cpython-5ad85f81b0664fafcd936b1dbfb728a3ace8f7a2.tar.bz2
Added example for str.format_map().
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/stdtypes.rst12
1 files changed, 10 insertions, 2 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index ebe7b76..0ac870b 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1042,9 +1042,17 @@ functions based on regular expressions.
Similar to ``str.format(**mapping)``, except that ``mapping`` is
used directly and not copied to a :class:`dict` . This is useful
- if for example ``mapping`` is a dict subclass.
+ if for example ``mapping`` is a dict subclass:
+
+ >>> class Default(dict):
+ ... def __missing__(self, key):
+ ... return key
+ ...
+ >>> '{name} was born in {country}'.format_map(Default(name='Guido'))
+ 'Guido was born in country'
+
+ .. versionadded:: 3.2
- .. versionadded:: 3.2
.. method:: str.index(sub[, start[, end]])