On Wed, Apr 15, 2020 at 2:09 PM Raymond Hettinger
<raymond.hettin...@gmail.com> wrote:
>
> [GvR]
> > We should not try to import JavaScript's object model into Python.
>
> Yes, I get that.  Just want to point-out that working with heavily nested 
> dictionaries (typical for JSON) is no fun with square brackets and quotation 
> marks.
>

My solution to that has usually been something along the lines of:

def get(obj, path):
    for step in path.split("-"):
        obj = obj[step]
    return obj

print(get(catalog, 'clothing-mens-shoes-extra_wide-quantity'))

Will often be custom-tweaked to the situation, but the basic idea is the same.

ChrisA
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/XNCNGO3PYOTFVWKTYCO6T57JW3YH24D4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to