[Zope3-dev] Importing

Chris Withers chrisw@nipltd.com
Thu, 13 Dec 2001 15:44:32 +0000


Guido van Rossum wrote:
> 
> > /package1/
> > /package1/package2a/modulea
> > /package1/package2a/package2b/mobuleb
> >
> > ...then when package 2 is being used on its own, I could do the following in
> > moduleb:
> 
> What do you mean by "on its own?". 

When package2a is on sys.path, I guess...

> I'm afraid that you mean that
> /package1 is on sys.path?  That's evil!

Urm, don't understand why ti's evil, can you explain?
I thougth beign on sys.path was the onyl way a package could be imported?

> > from package2a.modulea import someclass
> >
> > However, as soon as package2a is installed as a sub-package of package1, then
> > I'd have to change that import statement to:
> >
> > from package1.package2a.modulea import someclass
> >
> > ...or am I missign something?
> 
> No, we just disagree on the desirability of all this. 

It would appear so ;-)

> (for the *reader*, it's hard enough to figure out where to look for
> modules without multiple levels of relative import).

Why? if it's a relative import it should merely be backtracking a couple of
levels up the file system path...

> But others have
> occasionally asked for this too.  We should make it a PEP and reject
> it for clarity.  (PEP 667 anyone?)

Well, all except the reject bit ;-)

I don't think I have the best solution but there's soemthing that feels
sub-optimal about the current solution too...

cheers,

Chris