June 2019
Beginner to intermediate
770 pages
19h 24m
English
If we want to provide for default values by integrating multiple configuration files, we can't use both ChainMap and a nested dictionary-of-dictionaries like this. We have to either flatten out our program's parameters or look at an alternative to merging the parameters from different sources.
We can easily flatten the names by using simple . separators between names to reflect a top-level section and a lower-level property within the section. In that case, our JSON file might look like the following code:
{'player.betting': 'Flat', 'player.play': 'SomeStrategy', 'player.rounds': '100', 'player.stake': '50', 'simulator.outputfile': 'data/ch14_simulation5.dat', 'simulator.samples': '100', 'table.dealer': ...Read now
Unlock full access