Python Forum
how can I organise my code : best practice? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: how can I organise my code : best practice? (/thread-42187.html)



how can I organise my code : best practice? - pythonbum - May-24-2024

Hello
I have a long script I want to simplfy
Right now, i have main.py file which call lots of functions.
all my functions are defined in a helper.py file and a all_logix.py file which are in a folder named utils.

in helper.py, i have basic functions which are used by functions in all_logic.py
here are my folders:

myapp/
├── main.py
├── utils/
│ └── helper.py
│ ├── all_logics.py1
│ └── __init__.py

as such, main.py is something like this:
call all_logic.function1
call all_logic.function2
call all_logic.function3
call all_logic.function4
call all_logic.function5
....
call all_logic.function20
i'dl like to groupe some logic in the same python file.
le'ts say the first 5 logics belong to a theme, the next 5 to another theme and so on
I'd like to have something like
call logic_theme1.execution ()
call logic_theme2.execution ()
call logic_theme3.execution ()
call logic_theme4.execution ()
How shloud i organise my folder and files?
I'm thinking about this:
myapp/
├── main.py
├── utils/
│...└── helper.py
│...└── __init__.py
│...├── theme1/
│............├── logic_theme1.py
│...├── theme2/
│............├── logic_theme2.py
│...├── theme3/
│............├── logic_theme3.py


and then in logic_theme1.py, i'll have all the functions and another function named execution() which alls all these functions.

or should i have in logic_theme1.py only one function which is execution() and write all the function in another file?
myapp/
├── main.py
├── utils/
│...└── helper.py
│...└── __init__.py
│...├── theme1/
│.............├── logic_theme1.py
│.............├── utils_theme1/
│........................├── all_functions_theme1.py
│...├── theme2/
│..............├── logic_theme2.py
│..............├── utils_theme2/
│........................├── all_functions_theme2.py

what is the best practice?