Just load that and get the value from there, and don’t try to be fancy about it. Just load it right at the top of whatever file you have this function in.
Yes, that’s all you’re doing. I think though you might be missing a key thing that’s important about Python:
You can put any variable in a .py file and then import it directly. NO need to triple wrap it in a class. That means you could just do:
config.configs = { "uploads": "/path/to/uploads"}
But, you could also just do:
uploads = "/path/to/uploads"
Right in config.py, then just import that and use it directly rather than config.configs.uploads.
Basically, modules are dicts already, and objects are dicts already, so no need to put your dict inside an object inside a module.
P.S. If anyone tells you that objects/classes/modules are not dicts then ask them why they have a dict variable, or why globals() returns a dict. They’re just dicts with fancy syntax tacked on.
Thanks zed, so its just a question of utility then?
for a small application just for yourself you could just declare a variable in the file and use that, for larger applications where you want to be able to define something that can be changed easily by the end user.
you would use a config file and import that so things like categories, nav links, directory paths which are custom could be changed to suit without having to find each reference in the full application?