[Python-Dev] Re: [Import-sig] Re: Proposal for a modified import mechanism.

Prabhu Ramachandran Prabhu Ramachandran <prabhu@cyberwaveindia.com>
Mon, 12 Nov 2001 23:50:33 +0530

>>>>> "JH" == Jeremy Hylton <jeremy@zope.com> writes:

>>>>> "PR" == Prabhu Ramachandran <prabhu@aero.iitm.ernet.in> writes:
    PR> Ummm doing an 'import os' will import the package1/os.py and
    PR> *not* the standard one.  This will happen even though os.py
    PR> was imported earlier by site.py.  This is what Gordon was
    PR> objecting to in the first place and why he proposes using
    PR> rimport, rrimport etc. to make things more explicit.

    JH> Of course, you can use the existing mechanism to do this:
    JH> 'from package1 import os'.  The use of an explicit name seems
    JH> like the clearest route when you have a package-local module
    JH> that shadows a top-level module -- no need to understand
    JH> details of relative imports, no question about what is
    JH> intended by the code.

    JH> I haven't followed this thread closely.  Is there some reason
    JH> that explicit names in imports is not sufficient?

Yes indeed there is.  I've already explained my reasons twice.  Eric
also explained why this was important for Scipy.

Anyway, in short, its a big pain re-nesting packages.  Also for any
package that has a deep enough structure its a real pain accessing

from pkg import subpkg is also not the best way to do imports. I
personally prefer import pkg.subpkg and I believe this is the
recommended way of doing imports.