On Wed, Nov 29, 2017 at 7:21 AM, Daniel Moisset email@example.com wrote:
As reference of prior art, there is https://pypi.python.org/pypi/munch in PyPI
Box is also popular as it permits deeper nesting: https://pypi.python.org/pypi/python-box/ https://github.com/cdgriffith/Box Addict is similar: https://pypi.python.org/pypi/addict/2.1.1 https://github.com/mewwts/addict and I've seen AttrDict a few times in code I maintain: https://pypi.python.org/pypi/attrdict https://github.com/bcj/AttrDict
With a cursory search, also found: * DotMap: https://pypi.python.org/pypi/dotmap https://github.com/drgrib/dotmap * EasyDict https://pypi.python.org/pypi/easydict https://github.com/makinacorpus/easydict * Treedict (older) https://pypi.python.org/pypi/treedict * Bunch (older) https://pypi.python.org/pypi/bunch
...I spy a theme :P
Haven't dug into them that much, but I'd try to answer most questions with how they do it. I'm not sure if the recursive 'items as attributes within items as attributes...' feature is a can of worms or if it's something like defaultdict(dict), but with more levels. Getting deeply nested items with dots seems to be the usual use (i.e. complicated JSONs), and I think the degree of laziness in creating/setting nested items is variable.