Mercurial > cpython-lru_cache-weakref
diff Doc/lib/libfuncs.tex @ 25887:529da505eabc legacy-trunk
Modify example to use string methods instead of the string module.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Tue, 22 Oct 2002 20:31:22 +0000 |
| parents | b48a236b8c7b |
| children | 152219807144 |
line wrap: on
line diff
--- a/Doc/lib/libfuncs.tex Tue Oct 22 20:20:20 2002 +0000 +++ b/Doc/lib/libfuncs.tex Tue Oct 22 20:31:22 2002 +0000 @@ -37,7 +37,7 @@ a non-empty \var{fromlist} argument is given, the module named by \var{name} is returned. This is done for compatibility with the 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 spam.ham import eggs}, the \code{spam.ham} subpackage must be used to find the \code{eggs} variable. As a workaround for this @@ -45,11 +45,9 @@ components. For example, you could define the following helper: \begin{verbatim} -import string - def my_import(name): mod = __import__(name) - components = string.split(name, '.') + components = name.split('.') for comp in components[1:]: mod = getattr(mod, comp) return mod
