[Python-Dev] Re: [Import-sig] Re: Proposal for a modified import
Mon, 12 Nov 2001 13:35:47 -0500 (EST)
>>>>> "PR" == Prabhu Ramachandran <email@example.com> writes:
>>>>> "JH" == Jeremy Hylton <firstname.lastname@example.org> writes:
JH> I haven't followed this thread closely. Is there some reason
JH> that explicit names in imports is not sufficient?
PR> Yes indeed there is. I've already explained my reasons twice.
PR> Eric also explained why this was important for Scipy.
I've gone back through the messages on python-dev, but don't seem a
clear summary of the issues that lead to your proposed change. The
best I can come up with are: 1) packages that are re-nested are a pain
and 2) complex package structures also cause problems. Eric has a
specific set of issues with SciPy that involve packages that are
developed and used externally but also included in SciPy.
I have had a hard time trying to figure out precisely what the
PR> Anyway, in short, its a big pain re-nesting packages. Also for
PR> any package that has a deep enough structure its a real pain
PR> accessing packages.
What does "re-nesting" mean? It get the impression you mean
putting one package inside another after it was developed and pacakged
for use as a top-level package. If so, it doesn't seem like a problem
that occurs that often, right? I'd be hesitant to add features to the
import mechanism to cater to an infrequent case.
I'd rather see the imports be explicit "import root.a.b.c" than
"import b.c". Then re-nesting requires all the import statements to
be edited. It's more typing and might even require a simple script to
do search-and-replace, but it doesn't sound like a prohibitive
I expect there is more to the issue than just wanting to avoid some
extra typing. A short PEP that describes the specific problems being
solved and discussing alternatives would help.
PR> from pkg import subpkg is also not the best way to do imports. I
PR> personally prefer import pkg.subpkg and I believe this is the
PR> recommended way of doing imports.
Why do you think this is the recommended way of doing imports? I use
both in my code and haven't been able to come up with a clear
rationale for doing one or the other. The from ... import form seems
useful when the name of the package/module is long or when it's only
one or two names I'm using.