티스토리 뷰

공부

[Python] import modules of parent

승가비 2021. 1. 9. 00:08
728x90
import inspect
import os
import sys

currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)

https://stackoverflow.com/questions/714063/importing-modules-from-parent-folder

 

Importing modules from parent folder

I am running Python 2.5. This is my folder tree: ptdraft/ nib.py simulations/ life/ life.py (I also have __init__.py in each folder, omitted here for readability) How do I import ...

stackoverflow.com

 

728x90
댓글