inspite of proper package structure, no module named xyz error.
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Thu Jul 12 21:50:36 EDT 2007
En Thu, 12 Jul 2007 16:54:24 -0300, krishnakant Mane
<researchbase at gmail.com> escribió:
> hello all,
> can some one suggest me the best solution for a package?
> I have a package folder called idm and there are the following files in
> there.
> __init__.py which is right now empty.
> mainwindow.py which has a single class called MainWindow which is an
> MDI Parent frame from wxpython.
> student.py which is a child frame which gets called from the main menu.
> exam.py, another child frame.
> now when I try to run mainwindow.py file with the "import
> idm"statement, I get the following error.
> no module named idm.
I would avoid importing the package itself from inside of it. That is,
from the *outside*, import idm as any other client would do. And from
*inside* the package, import the relevant parts using relative imports.
I'm not convinced this is absolutely the right way to do things, but at
least it's less bug prone.
--
Gabriel Genellina
More information about the Python-list
mailing list