Commit d6cf8bea authored by Fred Drake's avatar Fred Drake

Modify example to use string methods instead of the string module.

parent 4b247264
...@@ -37,7 +37,7 @@ are always available. They are listed here in alphabetical order. ...@@ -37,7 +37,7 @@ are always available. They are listed here in alphabetical order.
a non-empty \var{fromlist} argument is given, the module named by a non-empty \var{fromlist} argument is given, the module named by
\var{name} is returned. This is done for compatibility with the \var{name} is returned. This is done for compatibility with the
bytecode generated for the different kinds of import statement; when bytecode generated for the different kinds of import statement; when
using \samp{import spam.ham.eggs}, the top-level package \code{spam} using \samp{import spam.ham.eggs}, the top-level package \module{spam}
must be placed in the importing namespace, but when using \samp{from must be placed in the importing namespace, but when using \samp{from
spam.ham import eggs}, the \code{spam.ham} subpackage must be used spam.ham import eggs}, the \code{spam.ham} subpackage must be used
to find the \code{eggs} variable. As a workaround for this to find the \code{eggs} variable. As a workaround for this
...@@ -45,11 +45,9 @@ are always available. They are listed here in alphabetical order. ...@@ -45,11 +45,9 @@ are always available. They are listed here in alphabetical order.
components. For example, you could define the following helper: components. For example, you could define the following helper:
\begin{verbatim} \begin{verbatim}
import string
def my_import(name): def my_import(name):
mod = __import__(name) mod = __import__(name)
components = string.split(name, '.') components = name.split('.')
for comp in components[1:]: for comp in components[1:]:
mod = getattr(mod, comp) mod = getattr(mod, comp)
return mod return mod
......
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