Open asaff1 opened 4 years ago
Thank you for your interest in config42. Yes, as_dict() returns only the parameters read by the configuration manager (config42. The defaults params are accessible by calling them directly by using the config.get("your.param.key").
Do you prefer having a method to return the mixed configuration parameters containing the defaults params? like = as_dict(defaults=True)
1) Actually I'm not sure what as_dict() is supposed to do. Does it returns the configuration values, or a dict description of the configuration?
Can you explain how the defaults
argument is used here?
https://config42.readthedocs.io/en/latest/tutorial.html#step-4-run-multiple-instances-of-shortly
2) I think the __iter__
method of ConfigManager
is not implemented as it should, currently it only dumps the keys, which means that list(config_manager)
does work, but dict(config_manager)
does not.
I would refactor it to include defaults and to yield a pair, which will make it possible to dump the configuration with dict(config_manager)
. This is somewhat a breaking change for the API, but I think it does make sense.
Your suggested way is ok for me though. Also, the library could support to output in as a nested dict, or as a flat dict.
yes, a PR is really appreciated!
Check this or we will delete your issue. (fill in the checkbox with an X like so: [x])
Select one:
Operating System? (include version)
Python Version Requirement
Exact Python Version?
Pip Version?
Description of your issue
I hoped there's an easy way to print the final configuration, with defaults included. The
as_dict
method is not very useful for this:Running
APP_A="" python myapp.py
prints:config: {'a': ''}
The problem: 'b' not included.Also I think it should be possible to get a dict representation of the entire final config, I'm surprised that
dict(config_manager)
does not work. Is that on purpose?