Commit 88f645a8 authored by Fred Drake's avatar Fred Drake

Call string substitution "substitution" instead of "interpolation". As Shane

pointed out, interpolation is a bad name for this, since it implies something
different.
parent d4749251
......@@ -507,10 +507,10 @@ This module provides a single function:
\end{funcdesc}
\section{\module{ZConfig.Interpolation} --- String interpolation}
\section{\module{ZConfig.Substitution} --- String substitution}
\declaremodule{}{ZConfig.Interpolation}
\modulesynopsis{Shell-style string interpolation helper}
\declaremodule{}{ZConfig.Substitution}
\modulesynopsis{Shell-style string substitution helper}
This module provides a basic substitution facility similar to that
found in the Bourne shell (\program{sh} on most \UNIX{} platforms).
......@@ -543,40 +543,40 @@ For these functions, the \var{mapping} argument can be a \class{dict},
or any type that supports the \method{get()} method of the mapping
protocol.
\begin{funcdesc}{interpolate}{s, mapping}
Interpolate values from \var{mapping} into \var{s}. Replacement
\begin{funcdesc}{substitute}{s, mapping}
Substitute values from \var{mapping} into \var{s}. Replacement
values are copied into the result without further interpretation.
Raises \exception{InterpolationSyntaxError} if there are malformed
Raises \exception{SubstitutionSyntaxError} if there are malformed
constructs in \var{s}.
\end{funcdesc}
\begin{funcdesc}{get}{mapping, name\optional{, default}}
Return the value for \var{name} from \var{mapping}, interpolating
Return the value for \var{name} from \var{mapping}, replacing
values recursively if needed. If \var{name} cannot be found in
\var{mapping}, \var{default} is returned without being
interpolated.
Raises \exception{InterpolationSyntaxError} if there are malformed
constructs in \var{s}, or \exception{InterpolationRecursionError} if
replaced.
Raises \exception{SubstitutionSyntaxError} if there are malformed
constructs in \var{s}, or \exception{SubstitutionRecursionError} if
any name expands to include a reference to itself either directly or
indirectly.
\end{funcdesc}
The following exceptions are defined:
\begin{excdesc}{InterpolationError}
Base class for errors raised by the \module{ZConfig.Interpolation}
\begin{excdesc}{SubstitutionError}
Base class for errors raised by the \module{ZConfig.Substitution}
module. Instances provide the attributes \member{message} and
\member{context}. \member{message} contains a description of the
error. \member{context} is either \code{None} or a list of names
that have been looked up in the case of nested interpolation.
that have been looked up in the case of nested substitution.
\end{excdesc}
\begin{excdesc}{InterpolationSyntaxError}
Raised when interpolation source text contains syntactical errors.
\begin{excdesc}{SubstitutionSyntaxError}
Raised when the source text contains syntactical errors.
\end{excdesc}
\begin{excdesc}{InterpolationRecursionError}
Raised when a nested interpolation is recursive. The
\begin{excdesc}{SubstitutionRecursionError}
Raised when a nested substitution is recursive. The
\member{context} attribute will always be a list for this
exception. An additional attribute, \member{name}, gives the name
for which an recursive reference was detected.
......@@ -585,18 +585,18 @@ The following exceptions are defined:
\subsection{Examples}
These examples show how \function{get()} and \function{interpolate()}
These examples show how \function{get()} and \function{substitute()}
differ.
\begin{verbatim}
>>> from ZConfig.Interpolation import get, interpolate
>>> from ZConfig.Substitution import get, substitute
>>> d = {'name': 'value',
... 'top': '$middle',
... 'middle' : 'bottom'}
>>>
>>> interpolate('$name', d)
>>> substitute('$name', d)
'value'
>>> interpolate('$top', d)
>>> substitute('$top', d)
'$middle'
>>>
>>> get(d, 'name')
......
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