I'm looking at creating my first packages to clean up my codebase.
Below is a very simplified version of my current project structure:
my_project/ |-database.py |-app_1.py |-app_2.py |-constants.py
To explain each one a little bit:
database.py- all the sqlalchemy orm table classes used by
app_1.py- an application that interacts with the database
app_2.py- an application that interacts with the database
constants.py- a range of constants used by different combos of the other files
Worth mentioning that in real life each one of the first three files is actually multiple folders and dozens of files.
To clean things up I'm considering creating packages for the first three files however I'm not sure how to deal with the constants. In some cases they are used in all of the first three files.
I've come up with three possible options:
- Duplicate the constants in each of the packages
- Create a dedicated constants package and import within each package
- Create a constants text file with all the constants and load it from each package
Option 1 doesn't seem like good coding practice and I can't find any references to anyone going with Option 2. This seems to leave me with Option 3. However, I then can't think where I would store the text file as it doesn't have a natural repository home!
Is there a best practice way to deal with the situation I'm facing?