Have you got troubles with configs? I have. And it's problem for me.
I have created simple and awesome library for configs parsing.
You can install it with pip:
pip install betterconf
from betterconf import field, Config class MyConfig(Config): my_var = field("my_var") cfg = MyConfig() print(cfg.my_var)
And.. run it!
my_var=1 python our_file.py
Also you can find it at github
Top comments (8)
As a suggestion, it would be useful for you to elaborate when one would use this, and what the problems it solves are.
Currently, If I don't look at the code, I imagine that it is a way of creating static classes to define variables we expect to find in the env, so I would then guess that is a class that wraps the os.environ, so maybe add to try to clarify in the readme.
Also you could state what sort of behaviour would be expected when values aren't found in the env.
Looking at the code, I see your function 'field' just returns a Field class. This seems like it was inspired by the dataclasses module, which is fun because you could then look at adding the 'default' parameter to handle values not found in the env. 🙂
Thanks! I will add default, it looks good for me.
Great first post, really valuable 🙂
Is it something around
os.getenv, where you can have default values? Or what is the point?
Hi! Now - not. You can see on github what i have updated.
Great Work :)