summaryrefslogtreecommitdiff
path: root/Doc/library/string.rst
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-04-25 01:59:09 +0000
committerBenjamin Peterson <benjamin@python.org>2008-04-25 01:59:09 +0000
commit1d3227e5f9f7acf2275f31ba44dffaf60262b824 (patch)
tree83462006efe4ed692d231a1a48dc7e6068fcf594 /Doc/library/string.rst
parentb908467e23de983449e97fc6d253b277101d01ef (diff)
downloadcpython-1d3227e5f9f7acf2275f31ba44dffaf60262b824.tar.gz
Merged revisions 62490 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r62490 | benjamin.peterson | 2008-04-24 20:29:10 -0500 (Thu, 24 Apr 2008) | 2 lines reformat some documentation of classes so methods and attributes are under the class directive ........
Diffstat (limited to 'Doc/library/string.rst')
-rw-r--r--Doc/library/string.rst36
1 files changed, 18 insertions, 18 deletions
diff --git a/Doc/library/string.rst b/Doc/library/string.rst
index b5fa4f7c63..99c2c80d20 100644
--- a/Doc/library/string.rst
+++ b/Doc/library/string.rst
@@ -452,29 +452,29 @@ these rules. The methods of :class:`Template` are:
The constructor takes a single argument which is the template string.
-.. method:: Template.substitute(mapping[, **kws])
+ .. method:: substitute(mapping[, **kws])
- Performs the template substitution, returning a new string. *mapping* is any
- dictionary-like object with keys that match the placeholders in the template.
- Alternatively, you can provide keyword arguments, where the keywords are the
- placeholders. When both *mapping* and *kws* are given and there are duplicates,
- the placeholders from *kws* take precedence.
+ Performs the template substitution, returning a new string. *mapping* is
+ any dictionary-like object with keys that match the placeholders in the
+ template. Alternatively, you can provide keyword arguments, where the
+ keywords are the placeholders. When both *mapping* and *kws* are given
+ and there are duplicates, the placeholders from *kws* take precedence.
-.. method:: Template.safe_substitute(mapping[, **kws])
+ .. method:: safe_substitute(mapping[, **kws])
- Like :meth:`substitute`, except that if placeholders are missing from *mapping*
- and *kws*, instead of raising a :exc:`KeyError` exception, the original
- placeholder will appear in the resulting string intact. Also, unlike with
- :meth:`substitute`, any other appearances of the ``$`` will simply return ``$``
- instead of raising :exc:`ValueError`.
+ Like :meth:`substitute`, except that if placeholders are missing from
+ *mapping* and *kws*, instead of raising a :exc:`KeyError` exception, the
+ original placeholder will appear in the resulting string intact. Also,
+ unlike with :meth:`substitute`, any other appearances of the ``$`` will
+ simply return ``$`` instead of raising :exc:`ValueError`.
- While other exceptions may still occur, this method is called "safe" because
- substitutions always tries to return a usable string instead of raising an
- exception. In another sense, :meth:`safe_substitute` may be anything other than
- safe, since it will silently ignore malformed templates containing dangling
- delimiters, unmatched braces, or placeholders that are not valid Python
- identifiers.
+ While other exceptions may still occur, this method is called "safe"
+ because substitutions always tries to return a usable string instead of
+ raising an exception. In another sense, :meth:`safe_substitute` may be
+ anything other than safe, since it will silently ignore malformed
+ templates containing dangling delimiters, unmatched braces, or
+ placeholders that are not valid Python identifiers.
:class:`Template` instances also provide one public data attribute: