[Import-sig] Why add '' to sys.path if there's an __init__.py?
Fred L. Drake, Jr.
Mon, 2 Oct 2000 19:34:10 -0400 (EDT)
This relates to SourceForge bug report #115528:
This reports a problem that I vaguely recall having heard complaints
about before. Essentially, the user is running Python with a script
stored in the same directory as the contents of a package:
The complaint is that "module" can be imported as "module" (in the
top-level "unnamed" package), and as "foo.module", where it should
be. I don't think this is actually a bug (which is why I've closed
the report), but it is clearly something that gets in the way of real
I think we get better behavior if we remove '' from sys.path if
there's an __init__.py file present; importing foo.module would still
work, but import module would raise an ImportError exception.
Fred L. Drake, Jr. <fdrake at beopen.com>
BeOpen PythonLabs Team Member