diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2006-04-03 04:48:37 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2006-04-03 04:48:37 (GMT) |
commit | 92e212f7d95f4c1071f6e2ea0b85cfb36a562814 (patch) | |
tree | 8be27745d01e1e729a1116b8ec1771e8f07cab6c /Doc | |
parent | 92a6be4318a961141ab61ac1d7dceac9634edd80 (diff) | |
download | cpython-92e212f7d95f4c1071f6e2ea0b85cfb36a562814.zip cpython-92e212f7d95f4c1071f6e2ea0b85cfb36a562814.tar.gz cpython-92e212f7d95f4c1071f6e2ea0b85cfb36a562814.tar.bz2 |
Accept keyword arguments for __import__ and doc the addition of the level param from PEP 328.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/lib/libfuncs.tex | 15 |
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} |