Possible Duplicate:
How to do relative imports in Python?
How do I import from a higher level directory in python.
For example:
I have project/lib/lib.py project/stuff/main.py
i want to import lib.py in main.py
Thanks in advance
You can do it like:
from ..lib import lib
standard method is to add project to your path and do
import lib.lib
You will need a file called __init__.py
in the lib folder as well, which can be blank.
精彩评论