15 Apr
2020
15 Apr
'20
4:13 a.m.
On Wed, Apr 15, 2020 at 2:09 PM Raymond Hettinger <raymond.hettinger@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