Skip to content

Comment on Box: Python dictionaries with advanced dot notation access

Comments

Reminds me of glom[1], another Python library that allows for traversing dicts using dot notation.

  >>> data = {'a': {'b': {'c': 'd'}}}
  >>> glom(data, 'a.b.c')
  'd'
Box uses a slightly different approach.
  >>> data = Box({'a': {'b': {'c': 'd'}}})
  >>> data.a.b.c
  'd'
I didn't see anything in the README about type inference, which would make the later example more desirable in my opinion. Otherwise I would prefer not to introduce a new container class to my code (Box) if avoidable.

[1] https://github.com/mahmoud/glom

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.