PEP 584: Fix order in specification examples (#1643)

Updating an existing key's value doesn't move it to the back.
This commit is contained in:
Stefan Pochmann 2020-10-09 19:05:24 +02:00 committed by GitHub
parent ada9ee667f
commit a0a8919aff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -152,7 +152,7 @@ the last-seen value (i.e. that from the right-hand operand) wins::
>>> d | e
{'spam': 1, 'eggs': 2, 'cheese': 'cheddar', 'aardvark': 'Ethel'}
>>> e | d
{'aardvark': 'Ethel', 'spam': 1, 'eggs': 2, 'cheese': 3}
{'cheese': 3, 'aardvark': 'Ethel', 'spam': 1, 'eggs': 2}
The augmented assignment version operates in-place::
@ -174,7 +174,7 @@ accept any iterable, not just lists. Continued from above::
>>> d |= [('spam', 999)]
>>> d
{'eggs': 2, 'cheese': 'cheddar', 'aardvark': 'Ethel', 'spam': 999}
{'spam': 999, 'eggs': 2, 'cheese': 'cheddar', 'aardvark': 'Ethel'}
When new keys are added, their order matches their order within the
right-hand mapping, if any exists for its type.
@ -580,7 +580,7 @@ Advantages
* Accepts sequences of ``(key, value)`` pairs like the ``update``
method.
* Being a method, it is easily to override in a subclass if you need
* Being a method, it is easy to override in a subclass if you need
alternative behaviors such as "first wins", "unique keys", etc.