Kaydet (Commit) 5ad85f81 authored tarafından Eric Smith's avatar Eric Smith

Added example for str.format_map().

üst 7322fcf8
......@@ -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]])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment