Importing of packages problem

Discussion in 'Python' started by Rogue 9, Jul 4, 2003.

  1. Rogue 9

    Rogue 9 Guest

    Hi All,
    I am developing a program called oop_lb.py and it's package structure is
    as below:

    oop_lb
    |
    --------------------------------------
    | | |
    analysis process tests

    I am using the unittest module and taking a leaf out of the Xtreme
    programming philosophy in as much as I am creating test modules for each
    module in the program and placing them in the tests package.The analysis
    and process packages contain a number of modules and I only
    encounteredproblems when I started writing the modules and tests for the
    analysis package.

    Put simply my problem is that modules in the analysis package reference
    modules in the process package and I can't seem to find a way of writing
    the import statements so that the tests and oop_lb.py will both execute
    without errors such as:

    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 13, in ?
    from process import GetDraw
    ImportError: No module named process

    If I change the import statement so that the test works then the oop_lb.py
    module will not run and gives the following message:

    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 ?
    from oop_lb.process import 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

    I hope I haven't been too ambiguous in my request and choice of listings
    to illustrate what I mean.If you can help that would be great and if I
    need to add something to make it clearer what it is I mean just let me
    know.
    Thanks ,Lol

    --
    Remove NOSPAM from my email address to use it,please.
    Rogue 9, Jul 4, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul  Smith
    Replies:
    0
    Views:
    718
    Paul Smith
    Nov 18, 2003
  2. IShai
    Replies:
    1
    Views:
    1,469
    Anton Spaans
    Nov 25, 2003
  3. Alban Hertroys

    Problem importing packages

    Alban Hertroys, Apr 28, 2004, in forum: Python
    Replies:
    1
    Views:
    275
    Alban Hertroys
    Apr 28, 2004
  4. David Lyon
    Replies:
    19
    Views:
    556
    David Lyon
    Apr 24, 2009
  5. Ian
    Replies:
    3
    Views:
    158
Loading...

Share This Page