I have a code base consisting of multiple scripts and many functions. Everything is controlled from one master script (
master.txt, let's say).
I have a lot of "global" configuration files, for example the URL, login, and password of the webservice I'm communicating with (this changes between test and production), and some tuning parameters for an optimization algorithm hidden deep inside the other scripts.
I want to configure these parameters often, and preferably easily. What is the best way to do this?
So far, I thought of the following options:
- A global variable
parametersdefined at the beginning, that stores all these options and is accessed from within the deep functions
- A variable
parametersthat is defined at the beginning, and passed down as an additional function argument in each function call
- A text file such as
parameters.yamlthat is read every time a function needs to access a value from it.
Currently, I am using the first option, but it doesn't feel right, since the functions are accessing data that is not passed to them. On the other hand, the second option makes every function call unnecessarily complex by adding an additional argument.
Surely I'm not the first guy with this problem and there exists a standard solution for this, right?