Skip to content

Commit

Permalink
Fix indentation in json.AttrDict REPL example (pythonGH-104930)
Browse files Browse the repository at this point in the history
This is causing the docs to be rendered incorrectly.
(cherry picked from commit 38539ef)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
  • Loading branch information
AlexWaygood authored and miss-islington committed May 25, 2023
1 parent 1a47d11 commit 284e81b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Doc/library/json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -559,14 +559,14 @@ Exceptions

.. 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'])
>>> 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
Expand Down

0 comments on commit 284e81b

Please # to comment.