summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libfuncs.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/lib/libfuncs.tex')
-rw-r--r--Doc/lib/libfuncs.tex15
1 files changed, 12 insertions, 3 deletions
diff --git a/Doc/lib/libfuncs.tex b/Doc/lib/libfuncs.tex
index ec9bd7b..686db39 100644
--- a/Doc/lib/libfuncs.tex
+++ b/Doc/lib/libfuncs.tex
@@ -6,7 +6,7 @@ are always available. They are listed here in alphabetical order.
\setindexsubitem{(built-in function)}
-\begin{funcdesc}{__import__}{name\optional{, globals\optional{, locals\optional{, fromlist}}}}
+\begin{funcdesc}{__import__}{name\optional{, globals\optional{, locals\optional{, fromlist\optional{, level}}}}}
This function is invoked by the \keyword{import}\stindex{import}
statement. It mainly exists so that you can replace it with another
function that has a compatible interface, in order to change the
@@ -20,9 +20,9 @@ are always available. They are listed here in alphabetical order.
For example, the statement \samp{import spam} results in the
following call: \code{__import__('spam',} \code{globals(),}
- \code{locals(), [])}; the statement \samp{from spam.ham import eggs}
+ \code{locals(), [], -1)}; the statement \samp{from spam.ham import eggs}
results in \samp{__import__('spam.ham', globals(), locals(),
- ['eggs'])}. Note that even though \code{locals()} and
+ ['eggs'], -1)}. Note that even though \code{locals()} and
\code{['eggs']} are passed in as arguments, the
\function{__import__()} function does not set the local variable
named \code{eggs}; this is done by subsequent code that is generated
@@ -52,6 +52,15 @@ def my_import(name):
mod = getattr(mod, comp)
return mod
\end{verbatim}
+
+ \var{level} specifies whether to use absolute or relative imports.
+ The default is \code{-1} which indicates both absolute and relative
+ imports will be attempted. \code{0} means only perform absolute imports.
+ Positive values for \var{level} indicate the number of parent directories
+ to search relative to the directory of the module calling
+ \function{__import__}.
+\versionchanged[The level parameter was added]{2.5}
+\versionchanged[Keyword support for parameters was added]{2.5}
\end{funcdesc}
\begin{funcdesc}{abs}{x}