Importing from upper packages

Henning Kage Henning.Kage at gmx.de
Tue Mar 1 21:45:17 CET 2005


I have a library with the following structure:

library
   /app
   /db
   /gui
      /interface.py
      /wx
         /class.py

Each __init__.py file imports the next sub-package. E.g.:

library/__init__.py: 
	import app, db, gui

library/gui/__init__.py: 
	import wx
	from interface import *

library/gui/wx/__init__.py:
	from class import *

>From the lowest layer "wx" I need to import an interface defined in the
gui package. Therefore I tried the following in library/gui/wx/class.py:

import library

class ClassTest( libor.gui.Interface):
   pass

I also set the PYTHONPATH to top directory, but I still get an
ImportError. How could this problem be solved or otherwise, how should I
import from upper packages in general? 

Thanks!



More information about the Python-list mailing list