Import statement help required by newbie please

Rogue 9 lol at
Fri Jul 4 22:58:51 CEST 2003

Hi All,
I have a small problem in a program I'm developing and could do with some
guidance as to how I resolve it.
The hierachy of my program is as follows:

1)The toplevel package is called oop_lb 2)Beneath oop_lb are 3 packages -
analysis,process and tests

	|			   |			      |
    analysis                    process                     tests

I am using the very excellent unittest module to help me to create a
program that is as bug free as I can make it and the tests are as you cn
guess in the tests package mentioned above. I have developed several
modules which reside in the process package and succesfully created tests
in the tests package which ensure the code does what I intended.When I
moved on to the analysis package however,things went a bit wonky as the
modules in this package called classes which resided in the process
package and when using the import statements to make them available I
found that either I could get the oop_lb module to run with one set of
import statements but the tests I wrote would not recognise the modules
from process in the import statements and produced the following type of

Traceback (most recent call last):
  File "", line 14, in ?
    import oop_lb.analysis.CalculateMedian
  File "/home/lol/disk/python/lotto/oop_lb/analysis/",
  line 14, in ?
    from process import GetDraw
ImportError: No module named process

This occurs with the following import statement in the

from process import GetDraw

If I change this to
import oop_lb.process.GetDraw

then the test program will work but the file fails with the
following error

Traceback (most recent call last):
  File "", line 21, in ?
    from analysis import CalculateMedian # import class definition from
  File "/home/lol/disk/python/lotto/oop_lb/analysis/",
  line 13, in ?
    import oop_lb.process.GetDraw
  File "/home/lol/disk/python/lotto/oop_lb/", line 21, in ?
    from analysis import CalculateMedian # import class definition from
ImportError: cannot import name CalculateMedian problem is that I can't seem to find the proper way to import
the modules to satisfy both the testing modules in the oop_lb.tests
package and also allow to run without import errors. I apologise
for the length of the post and any ambiguities I may not have managed to
clear up whilst proff reading this before posting.


Remove NOSPAM from my email address to use it,please.

More information about the Python-list mailing list