3
我用下面的文件夾結構構造我的Python應用程序導入(輪廓here大致如下):從另一個目錄
myapp:
myapp_service1:
myapp_service1_start.py
...
myapp_service2:
myapp_service2_start.py
...
myapp_service3:
myapp_service3_start.py
...
common:
myapp_common1.py
myapp_common2.py
myapp_common3.py
...
scripts:
script1.py
script2.py
script3.py
...
tests:
...
docs:
...
LICENSE.txt
MANIFEST.in
README
這是理想的文件/文件夾層次對我來說,但是,我對如何迷惑從外部文件夾引用模塊。例如,myapp_service1_start.py
需要引用myapp_common1.py
和myapp_common2.py
中的函數。
我知道我需要以某種方式添加對系統path
或pythonpath
的引用,但我不確定在代碼中執行此操作的最佳方式。或者甚至我甚至會在代碼中做到這一點。
我該怎麼做?
我已經看到了很多有關創建一個完整的Python包要通過安裝pip
職位的,但是這似乎有點小題大做了我。
作品完美! – Brett