Python Forum
how can I organise my code : best practice?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how can I organise my code : best practice?
#1
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Threading best practice EvanS1 2 2,041 Apr-21-2020, 10:11 PM
Last Post: EvanS1
  Condition check differences and how to organise code? adam2020 4 2,794 May-12-2019, 04:12 PM
Last Post: Yoriz
  Help with string practice Hermann_Fegelein 2 2,794 Aug-15-2018, 04:56 PM
Last Post: Hermann_Fegelein
  Best Practice For String Quotations ? Zork_3 9 50,298 Sep-01-2017, 07:16 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020