In your particular case, it looks like you are trying to import SomeObject from the myapp.py and TestCase.py scripts. From myapp.py do
import SomeObject
since it is in the same folder. For TestCase.py do
from ..myapp import SomeObject
However, this will only work if you import TestCase from the package. If you want to run python TestCase.py directly, you have to get confused with your path. This can be done in Python:
import sys sys.path.append("..") from myapp import SomeObject
although this is usually not recommended.
In general, if you want other people to use your Python package, you should use distutils to create a script setup. That way, anyone can easily install your package with a command like python setup.py install , and it will be available everywhere on their machine. If you are serious about a package, you can even add it to the Python package index, PyPI .
David Robinson Feb 21 '12 at 18:46 2012-02-21 18:46
source share