HNHacker News
TopNewBestAskShowJobs

chris_griffith

1 karma · joined May 5, 2017

submissionscomments
chris_griffith··on Box: Python dictionaries with recursive dot notation access
First things off top of head: Box does recursion through lists, new dicts (and lists of dicts) added will also be dot notation without manually converting, Box can be a recursive default dict, Box will allow keys with spaces or other issues to be accessible as attributes, and can be frozen, and has YAML and JSON functions built-in.
chris_griffith··on Box: Python dictionaries with recursive dot notation access
That is a very good point, never thought of that. I will have to add a feature to make that configurable. Thanks for the heads up!
chris_griffith··on Box: Python dictionaries with recursive dot notation access
Something like that would be handy. Just to clarify the addict mention.

It works similarity to addict, but does have important distinctions and IMO seniority (was in my 'reusables' pypi project named 'Namespace' before addict existed. Just finally spun it into it's own project).

Biggest differences:

* Box will convert items added to the object after creation, addict does not

* addict only acts as a defaultdict, Box can act as either regular or defaultdict

* Box updates it’s __dir__ so that attributes (keys) are tab completed in stuff like IPython

* Box repr clearly shows it is an object

chris_griffith··on Box: Python dictionaries with recursive dot notation access
Author here: I totally agree with the fact it has shortcomings and definitely isn't aimed to replace everyone's dict everywhere.

I actually created the first iteration of this around 3 years ago, aimed primarily for sysadmins and others who use the console more than actual developing. As I find it extremely convenient to tab complete keys and a lot less typing.

From there it has obviously evolved to try and fit more peoples needs, and I use it regularly in my projects.

chris_griffith··on Box: Python dictionaries with recursive dot notation access
Just finished my article that includes speed comparisons. http://www.codecalamity.com/python-box-3-the-reddit-release/...

Basically it's faster on standard soft creation as it converts on lookup. (And most use cases don't call for referencing every single key)