Import statement help required by newbie please

R

Rogue 9

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

oop_lb
|
|
-------------------------------------------------------
| | |
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
error:

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

This occurs with the following import statement in the CalculateMedian.py
module

from process import GetDraw

If I change this to
import oop_lb.process.GetDraw

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

Traceback (most recent call last):
File "oop_lb.py", line 21, in ?
from analysis import CalculateMedian # import class definition from
file
File "/home/lol/disk/python/lotto/oop_lb/analysis/CalculateMedian.py",
line 13, in ?
import oop_lb.process.GetDraw
File "/home/lol/disk/python/lotto/oop_lb/oop_lb.py", line 21, in ?
from analysis import CalculateMedian # import class definition from
file
ImportError: cannot import name CalculateMedian

So.....my 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 oop_lb.py 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.

Thanks,Lol
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top