Cross-reference 'import' in a class hierarchy

Patrick K. O'Brien pobrien at orbtech.com
Sun Apr 6 22:01:47 EDT 2003


Ben Finney <bignose-hates-spam at and-zip-does-too.com.au> writes:

> On Sun, 06 Apr 2003, Erik Max Francis wrote:
> >  Ben Finney wrote:
> > > In ork.py I want:
> > >     import eek
> >  
> > If the toplevel package is put in a place where Python can find it,
> >  	import monty.foo.eek
> 
> It's not.  Even if I make it so on my computer, it's not going to be so
> on someone else's computer when they download my package tree.

It will be if you tell them that's what's required.  That's how most
Python packages are distributed.  Put an __init__ in monty and foo,
and require users to put monty somewhere on their PYTHONPATH.  The
path to monty doesn't have to be directly in PYTHONPATH -- monty just
needs to be a child of some directory that is in PYTHONPATH.  For
example, I have a directory, ~/Code (C:\Code on Windows) that is in my
PYTHONPATH and then I just put all the various packages I work on as
subdirectories of ~/Code.  Other packages, like wxPython, IDLE, PIL,
Gtk, etc., install themselves in python2.2/site-packages, which is
also on the PYTHONPATH.

-- 
Patrick K. O'Brien
Orbtech      http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------




More information about the Python-list mailing list