How to properly structure internal scripts in a Python project?

后端 未结 7 1259
抹茶落季
抹茶落季 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条回答
  •  闹比i
    闹比i (楼主)
    2021-02-14 03:44

    You need to add __init__.py files to scripts and to proj folders for those to be considered Python packages and for you to be able to import from those.

    One way this is also commonly done, is to place your foo and scripts folders into a proj/src folder, which then has a __init__.py file, and thus is a Python package.

提交回复
热议问题