I currently have a small list (< 20) of constants that can be segmented into the following three parts:
- main script (tokens, log file location) - database setup (username, passwords) - API (API key, various external IDs)
I felt that it cluttered the top of the files during declaration, so I transferred them into a constants file. However, when importing them back to the three files, for instance say the database setup, it would become
import constants ... db = connect(constants.RDS_HOSTNAME, constants.RDS_PASSWORD)
compared to if I had declared them in the file
RDS_HOSTNAME = 'xxx' RDS_PASSWORD = 'yyy' ... db = connect(RDS_HOSTNAME, RDS_PASSWORD)
which I feel is a bit more readable when using the constants.
If I combine the both, I would have
from constants import * ... db = connect(RDS_HOSTNAME, RDS_PASSWORD)
but all posts I've read suggest very heavily against this as it would increase confusion due to not knowing where the constants come from.
My question is this: given that I have only one constants file with no functions, and all constants are upper case, would using
from constants import * nonetheless be poor practice? Due to the uppercase notation, I would know immediately it's a constant and comes from the constants file, thus reducing confusion.