[Zope3-dev] Importing

Jim Fulton jim@zope.com
Mon, 17 Dec 2001 15:50:59 -0500


Chris Withers wrote:
> 
> Jim Fulton wrote:
> >
> > > /something/__init__.py
> > > /something/somemodule.py
> > > /something/abit/__init__.py
> > > /something/abit/somemodule2.py
> > >
> > > ...you'd import the package like:
> > >
> > > import something
> > >
> > > BUT, how would you import a method/class in somemodule.py _from_ somemodule2.py?
> >
> > You have to say something like:
> >
> > from something.somemodule import someclass
> 
> Well, that would be fine, but what is you don't know where the root of your
> module path is?

Then you're in trouble. :]

> for example, say you write a package that could be used as a Zope product and as
> a simple python package.
> 
> if you do:
> 
> from mypackage.mymodule import someclass
> 
> ...it won't work in the Zope environment, or anywhere else where mypackage isn't
> directly on the python path.
> 
> Is that correct?

Right. Note, however, that Zope 3 won't care where you put it, so 
Zope need not be the cause of a problem here.

Jim

--
Jim Fulton           mailto:jim@zope.com       Python Powered!        
CTO                  (888) 344-4332            http://www.python.org  
Zope Corporation     http://www.zope.com       http://www.zope.org