[Import-sig] Why add '' to sys.path if there's an __init__.py?
Guido van Rossum
Mon, 02 Oct 2000 20:18:20 -0500
> 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.
> Comments please!
Very clever. But what if the package's (grand*)parent is *not* on
sys.path? I say it's a user error and that's that.
--Guido van Rossum (home page: http://www.python.org/~guido/)