[Python-checkins] python/nondist/peps pep-0302.txt,1.5,1.6
jvr@users.sourceforge.net
jvr@users.sourceforge.net
Thu, 26 Dec 2002 10:00:44 -0800
Update of /cvsroot/python/python/nondist/peps
In directory sc8-pr-cvs1:/tmp/cvs-serv30473
Modified Files:
pep-0302.txt
Log Message:
Fixed naive description of how relative imports work (spotted by Guido).
Index: pep-0302.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0302.txt,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** pep-0302.txt 24 Dec 2002 20:36:32 -0000 1.5
--- pep-0302.txt 26 Dec 2002 18:00:40 -0000 1.6
***************
*** 193,205 ****
The built-in __import__ function (known as PyImport_ImportModuleEx
in import.c) will then check to see whether the module doing the
! import is a package by looking for a __path__ variable in the
! current global namespace. If it is indeed a package, it first tries
! to do the import relative to the package. For example if a package
! named "spam" does "import eggs", it will first look for a module
! named "spam.eggs". If that fails, the import continues as an
absolute import: it will look for a module named "eggs". Dotted
name imports work pretty much the same: if package "spam" does
! "import eggs.bacon", first "spam.eggs.bacon" is tried, and only if
! that fails "eggs.bacon" is tried.
Deeper down in the mechanism, a dotted name import is split up by
--- 193,207 ----
The built-in __import__ function (known as PyImport_ImportModuleEx
in import.c) will then check to see whether the module doing the
! import is a package or a submodule of a package. If it is indeed a
! (submodule of a) package, it first tries to do the import relative
! to the package (the parent package for a submodule). For example if
! a package named "spam" does "import eggs", it will first look for a
! module named "spam.eggs". If that fails, the import continues as an
absolute import: it will look for a module named "eggs". Dotted
name imports work pretty much the same: if package "spam" does
! "import eggs.bacon" (and "spam.eggs" exists), "spam.eggs.bacon" is
! tried and if that fails "eggs.bacon" is tried. (There are more
! subtleties that are not described here, but these are not relevant
! for implementers if the Importer Protocol.)
Deeper down in the mechanism, a dotted name import is split up by