On Sun, Jul 20, 2008 at 12:46 PM, Oleg Oltar <[EMAIL PROTECTED]> wrote:
> Hi > I need to import several modules from many folders which has subfolders > > ~/folder/tests/sampletest.py > ~/folder/suites/samplesuit.py > > a suit uses tests from tests folder. I need to import them somehow from > tests folder. I added ~/folder to PYTHONPATH in my test_runner: > > > import sys > import os > > sys.path.insert(0, "~/folder") > os.popen("python2.5 %s" %sys.argv[1]) > > But when trying to import module in the samplesuite file: > > from tests.sampletest.EmailWithoutA import EmailWithoutA >> > > But I getting ImportError: No module named .... > > Please help > > Do you have an __init__.py file in the tests and suites directories? More on that here: http://docs.python.org/tut/node8.html "The __init__.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as "string", from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable, described later."
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor