次のように編成された一連のpythonスクリプトがあります。
PythonScripts/
TypeAScripts/
TypeASet1Scripts/
example.py
TypeASet2Scripts/
TypeBScripts/
TypeBSet1Scripts/
TypeBSet2Scripts/
TypeCScripts/
TypeCSet1Scripts/
TypeCSet2Scripts/
CommonFunctions/
CommonFunctions.py
init.pyすべてのフォルダで。私が欲しいのは、example.pywhere example.pyimports fromを実行できるようにすることCommonFunctionsです。フォルダー A、B、および C のスクリプトで同じことを行いたいと考えています。
絶対インポートでこれを行うには、次のようにします
import PythonScripts.CommonFunctions.CommonFunctions
ただし、これPythonScriptsは Python パスにある場合にのみ機能します。example.pyそのフォルダーで実行しているだけの場合は、そうではありません。で追加できますがsys.append()、これは厄介な方法のようです。より良いアプローチはありますか?