Python example making use of best practice file structure and multithreading.
made for python3+
project/
|
|-- anaconda/
| |-- runner.py (Main entrypoint)
| |-- __main__.py
| |-- hello/
| | |-- hello.py (hello module)
| | |-- helpers.py (helper functions for hello module)
| |
| |-- world/
| |-- world.py
| |-- helpers.py
|
|-- data/ (Data folder could contain input/output files like logs while testing the application)
| |-- input.txt
|
|-- docs/ (Bigger/more complicated apps should have documentation for each module)
| |- hello.md
| |- world.md
|
|-- readme.md (You are reading this one)
|-- LICENSE (Yes you should have a LICENSE)
|-- requirements.txt (Pip requirements to install)
|-- Makefile (A makefile could be used to automate tests and setup)
|-- .gitignore (files being ignored by git)
- Open the root as workspace folder and run
python3 -m anaconda
orpy -m anaconda
(depends on your path). - Setup and run with
make setup
to install dependencies andmake run
to run the script - Can't run this with the debug button i think. Learn some commands like
ctrl + ~
- Makefile uses Make. You can install that with
choco install make
while having Chocolatery installed. Or skip it all together.. - Opened up threads cant be closed with ctrl+c. If it chrases use your task manager. Should use a global variable for stopping it (like we are doing in this example) or change to classes with a function that raises an exeption
- the
__main__.py
in anaconda/ is there so we can run the module withpython3 -m anaconda
- This project doesnt use any pip dependencies, but its there as an example
- It might be better to thread a whole Class instead of a method (function)
BahbV bob@bahbv.net