Hacker News new | ask | show | jobs
by Halvedat 1050 days ago
Neither of these appear to have the chained attribute feature, from my surface level parse.
3 comments

python-box does this in the most intuitive way possible:

    >>> from box import Box
    >>> empty_box = Box(default_box=True)
    >>> empty_box.a.b.c.d.e.f.g # <Box: {}>
It's there on the readme/pypi home for both; unless i'm misunderstanding what you mean by "chained"

    from box import Box
    movie_box = Box({ "Robin Hood: Men in Tights": { "imdb stars": 6.7, "length": 104 } })
    movie_box.Robin_Hood_Men_in_Tights.imdb_stars


    from munch import Munch
    b = Munch()
    b.hello = 'world'
    b.foo = Munch(lol=True)
    b.foo.lol
Chained means in your second example this would work without manually creating a new instance:

    b.foo.lol = True