Relative import problem

Jorgen Bodde jorgen.maillist at
Thu Apr 19 18:54:50 CEST 2007

Hi all,

I want to structure my app so that I have two dirs like;

obj/{object files}

gui/{gui files}

Here comes the catch. From the GUI dir, I would like to access the obj
submodule path. I need to go one dir back.. I read there was something
like from .. import x in python 2.5 so that I could access my obj dir
from a lower level, but I have problems getting this to work.


In the main dir I have;
import gui


In the obj dir I have;


def start():
    print 'Started OBJ'

In the GUI dir I have

from .. import obj

def start():

This does not work. It gives me;

Traceback (most recent call last):
  File "", line 4, in <module>
AttributeError: 'module' object has no attribute 'gui'

Am I shooting myself in the foot by trying to structure? Or are there
better more elegant ways?

- Jorgen

More information about the Python-list mailing list