diff options
author | Ćukasz Langa <lukasz@langa.pl> | 2023-06-26 18:35:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-26 18:35:53 (GMT) |
commit | d3af83b9342457d8b24476baeb799f7506ff04f3 (patch) | |
tree | 39fb799db36fbd6184ca4d00b561a9643afe5485 /Doc/library | |
parent | 512f299e557f4ab60768d36cee9968bd92116367 (diff) | |
download | cpython-d3af83b9342457d8b24476baeb799f7506ff04f3.zip cpython-d3af83b9342457d8b24476baeb799f7506ff04f3.tar.gz cpython-d3af83b9342457d8b24476baeb799f7506ff04f3.tar.bz2 |
Revert "GH-96145: Add AttrDict to JSON module for use with object_hook (#96146)" (#105948)
This reverts commit 1f0eafa844bf5a380603d55e8d4b42d8c2a3439d.
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/json.rst | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/Doc/library/json.rst b/Doc/library/json.rst index ef58dd0..5383614 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -9,11 +9,6 @@ **Source code:** :source:`Lib/json/__init__.py` -.. testsetup:: * - - import json - from json import AttrDict - -------------- `JSON (JavaScript Object Notation) <https://json.org>`_, specified by @@ -548,44 +543,6 @@ Exceptions .. versionadded:: 3.5 -.. class:: AttrDict(**kwargs) - AttrDict(mapping, **kwargs) - AttrDict(iterable, **kwargs) - - Subclass of :class:`dict` that also supports attribute style dotted access. - - This class is intended for use with the :attr:`object_hook` in - :func:`json.load` and :func:`json.loads`: - - .. doctest:: - - >>> json_string = '{"mercury": 88, "venus": 225, "earth": 365, "mars": 687}' - >>> orbital_period = json.loads(json_string, object_hook=AttrDict) - >>> orbital_period['earth'] # Dict style lookup - 365 - >>> orbital_period.earth # Attribute style lookup - 365 - >>> orbital_period.keys() # All dict methods are present - dict_keys(['mercury', 'venus', 'earth', 'mars']) - - Attribute style access only works for keys that are valid attribute - names. In contrast, dictionary style access works for all keys. For - example, ``d.two words`` contains a space and is not syntactically - valid Python, so ``d["two words"]`` should be used instead. - - If a key has the same name as a dictionary method, then a dictionary - lookup finds the key and an attribute lookup finds the method: - - .. doctest:: - - >>> d = AttrDict(items=50) - >>> d['items'] # Lookup the key - 50 - >>> d.items() # Call the method - dict_items([('items', 50)]) - - .. versionadded:: 3.12 - Standard Compliance and Interoperability ---------------------------------------- |