dotmap icon indicating copy to clipboard operation
dotmap copied to clipboard

Immutable/frozen dotmap

Open worldmind opened this issue 6 years ago • 1 comments

Hi, I am searching a best type for config data, usually it is nested dict, but on my opinion config must:

  1. have dot notation for readability,
  2. be immutable for safe using (config is global variable). Can DotMap be immutable?

P.S. I found https://github.com/cdgriffith/Box/ but not sure that it popular = good tested.

worldmind avatar Apr 04 '19 11:04 worldmind

I usually use

configFile = yaml.safe_load(fileObject)
config = dotmap.DotMap(configFile, _dynamic = False)

which works fine. However It would be nice to be able to switch between dynamic and "static" DotMaps. For instance I want to load the config file, apply command line overrides (using argparse) and then lock the config. Currently I iterate over the DotMap and recursively set _dynamic to False.

sesquideus avatar Sep 19 '19 10:09 sesquideus