You can try something like:
import os.path, sys
sys.path.insert(0, "dir_or_path")
sys.path.insert(0, os.path.dirname(os.path.abspath(os.path.realpath(__file__))) + "/dir")
Which will add your directory to the Python search path. Then you can import as usual.
To find out which paths have been added, check:
import sys
from pprint import pprint
pprint(sys.path)
, , Python ( __init__.py ). , .
inline, Python 3 exec(), :
exec(open(filename).read())
Python 2: execfile().
: execfile Python 3.2+?
script , Python, PYTHONPATH, Python , .
PYTHONPATH=$PWD/FooDir ./foo.py
: Python?