How to properly structure internal scripts in a Python project?

后端 未结 7 1280
抹茶落季
抹茶落季 2021-02-14 02:58

Consider the following Python project skeleton:

proj/
├── foo
│   └── __init__.py
├── README.md
└── scripts
    └── run.py

In this case f

7条回答
  •  日久生厌
    2021-02-14 04:00

    another solution is you add a.pth file on your Python directory

    and write the content of the following,

    # your.pth 
    
    #↓ input the directory of proj
    C:\...\proj  
    

    done

    # scripts.py
    from foo import Foo
    Foo().run()
    

    It will work well.

    .. note:: If your IDE is PyCharm, then you can use the Source roots to help you too.

提交回复
热议问题