News for hackers. Stuff that matters.
Re:DotDict: A simple Python library to make chained attribut... by sidmitra on Wednesday August 02, 2023 @06:12PM (#36978464)
In case anyone is looking for mature alternatives that are used in production

https://pypi.org/project/python-box/

https://pypi.org/project/munch/

Re:DotDict: A simple Python library to make chained attribut... by Halvedat on Wednesday August 02, 2023 @06:45PM (#36978850)
Neither of these appear to have the chained attribute feature, from my surface level parse.
Re:DotDict: A simple Python library to make chained attribut... by jperras on Wednesday August 02, 2023 @07:38PM (#36979405)
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: {}>
Re:DotDict: A simple Python library to make chained attribut... by sidmitra on Wednesday August 02, 2023 @07:19PM (#36979241)
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
Re:DotDict: A simple Python library to make chained attribut... by Izkata on Wednesday August 02, 2023 @08:22PM (#36979742)
Chained means in your second example this would work without manually creating a new instance:

    b.foo.lol = True
Re:DotDict: A simple Python library to make chained attribut... by nmalaguti on Wednesday August 02, 2023 @06:48PM (#36978907)
Re:DotDict: A simple Python library to make chained attribut... by make3 on Wednesday August 02, 2023 @07:29PM (#36979332)
Munch is an unfortunate name
Re:DotDict: A simple Python library to make chained attribut... by KolenCh on Thursday August 03, 2023 @11:58AM (#36987663)
How does these compare to glom?

https://glom.readthedocs.io