I saw how people used monkey patch to set parameters in a module, for example:
import mymodule
mymodule.default_img = "/my/file.png"
mymodule.view_default_img ()
And Django, for example, has settings.py for the whole Django application, and it always solves me a bit.
What are other ways to manage configuration settings in a module? What is recommended? It often seems that there is no good way to configure the configuration at the module level.
Obviously, a complete configuration exception is most preferable, and it is usually best to use classes or pass an argument to a function. But sometimes you canβt avoid any settings, and sometimes it really makes sense to have global parameters for the whole module just for convenience (for example, the Django template system - specifying the base path for each template will be a nightmare, definitely not a good DRY code).
python
bryhoyt
source share