diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-04-25 01:59:09 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-04-25 01:59:09 (GMT) |
commit | e41251e864e94885d785b5a9bf8f824753316296 (patch) | |
tree | f530db7682d71f4920b22b8d7f84c89727647ab5 /Doc/library/string.rst | |
parent | 768db92b438038586c1580b711c528363a97d3f4 (diff) | |
download | cpython-e41251e864e94885d785b5a9bf8f824753316296.zip cpython-e41251e864e94885d785b5a9bf8f824753316296.tar.gz cpython-e41251e864e94885d785b5a9bf8f824753316296.tar.bz2 |
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.rst | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/Doc/library/string.rst b/Doc/library/string.rst index b5fa4f7..99c2c80 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: |