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