diff options
author | Brett Cannon <brett@python.org> | 2012-08-06 00:46:25 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-08-06 00:46:25 (GMT) |
commit | 9b000e7a6835e8f1899276be1d2dfebb651ce42b (patch) | |
tree | 8ed842957eb0d1119a4e8f2d9073b4bf8e5d3178 /Doc | |
parent | 03e2180b3f5c8fbbbf26e8ffc168ddf6269aba02 (diff) | |
download | cpython-9b000e7a6835e8f1899276be1d2dfebb651ce42b.zip cpython-9b000e7a6835e8f1899276be1d2dfebb651ce42b.tar.gz cpython-9b000e7a6835e8f1899276be1d2dfebb651ce42b.tar.bz2 |
Issue #15482: Properly document the default 'level' parameter for
__import__().
To help explain why the -1 default value is typically not seen, a note
about how import statements only use values of >= 0 is also noted.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/functions.rst | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 72bc7cb..5d6a5fe 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1410,7 +1410,7 @@ are always available. They are listed here in alphabetical order. True -.. function:: __import__(name, globals={}, locals={}, fromlist=[], level=0) +.. function:: __import__(name, globals={}, locals={}, fromlist=[], level=-1) .. index:: statement: import @@ -1435,10 +1435,13 @@ are always available. They are listed here in alphabetical order. not use its *locals* argument at all, and uses its *globals* only to determine the package context of the :keyword:`import` statement. - *level* specifies whether to use absolute or relative imports. ``0`` (the - default) means only perform absolute imports. Positive values for - *level* indicate the number of parent directories to search relative to the - directory of the module calling :func:`__import__`. + *level* specifies whether to use absolute or relative imports. ``0`` + means only perform absolute imports. Positive values for *level* indicate the + number of parent directories to search relative to the directory of the + module calling :func:`__import__`. Negative values attempt both an implicit + relative import and an absolute import (usage of negative values for *level* + are strongly discouraged as future versions of Python do not support such + values). Import statements only use values of 0 or greater. When the *name* variable is of the form ``package.module``, normally, the top-level package (the name up till the first dot) is returned, *not* the |