On Wed, Apr 15, 2020 at 2:59 PM Ivan Pozdeev via Python-Dev
<[email protected]> wrote:
> "Glom syntax" still excludes the delimiter, whatever it is, from use in keys.
> So it's still a further limitation compared to the JSON spec.
Glom does let you be specific about the exact lookup keys if you want,
to handle keys that contain embedded periods, or non-string keys. The
syntax looks like:
from glom import glom, Path
glom(obj, Path("a", "b.c", 2))
https://glom.readthedocs.io/en/latest/api.html#specifier-types
For a simple case like this t's a bit wordier than obj["a"]["b.c"][2],
but OTOH you get better error message on failed lookups,
null-coalescing support by using default=, etc.
-n
--
Nathaniel J. Smith -- https://vorpus.org
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/32Q7H5LLES3C2WUIYWTPICXGWWWP4UQU/
Code of Conduct: http://python.org/psf/codeofconduct/