For:
app/ __init__.py abc.py mod/ __init__.py def.py
How do I import abc.py from def.py?
to import the module 'abc.py', which is located in the parent directory of your current module:
import os parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) os.sys.path.insert(0,parentdir) import abc
in the def module, if you want to import say abc, just do:
from ..abc import *
Note: since def is a python keyword, using this name for a module does not seem like a good idea.