[Zope3-dev] Importing
Chris Withers
chrisw@nipltd.com
Wed, 12 Dec 2001 12:40:29 +0000
Guido van Rossum wrote:
>
> > Now, how should I be doing this? (and in Zope 3?)
>
> Ah, the relative import fallacy. Why is it required to be able to
> reparent a package without changing the source?
So that a package may be re-used as a sub-package in another package without
having to re-write or otherwise fudge all the import statements in the import
package.
> To me, always using
> absolute paths makes the most sense:
>
> from something.somemodule import someclass
>
> works independently from where the caller lives.
well, if i have:
/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:
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?
cheers,
Chris