This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fix instances in documentation where dictionaries are referenced as unordered
Type: Stage: resolved
Components: Documentation Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Dict order is now guaranteed, so add tests and doc for it
View: 32337
Assigned To: docs@python Nosy List: arjunv, docs@python, rhettinger
Priority: normal Keywords:

Created on 2018-04-03 20:26 by arjunv, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg314892 - (view) Author: arjun v (arjunv) Date: 2018-04-03 20:26
In python 3.6 (and above hopefully), dictionary keys are going to be ordered, while their documentation still reference them as being unordered.

https://docs.python.org/3/tutorial/datastructures.html#dictionaries 

1: `It is best to think of a dictionary as an unordered set of key: value pairs,...`

2: `Performing list(d.keys()) on a dictionary returns a list of all the keys used in the dictionary, in arbitrary order..`

The examples should also be changed to reflect the same:
```
>>> tel = {'jack': 4098, 'sape': 4139}
>>> tel['guido'] = 4127
>>> tel
{'sape': 4139, 'guido': 4127, 'jack': 4098}
>>> tel['jack']
4098
>>> del tel['sape']
>>> tel['irv'] = 4127
>>> tel
{'guido': 4127, 'irv': 4127, 'jack': 4098}
>>> list(tel.keys())
['irv', 'guido', 'jack']
>>> sorted(tel.keys())
['guido', 'irv', 'jack']
>>> 'guido' in tel
True
>>> 'jack' not in tel
False
```

```
>>> dict([('sape', 4139), ('guido', 4127), ('jack', 4098)])
{'sape': 4139, 'guido': 4127, 'jack': 4098}
```

```
>>> dict(sape=4139, guido=4127, jack=4098)
{'sape': 4139, 'guido': 4127, 'jack': 4098}
```
msg314914 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2018-04-04 04:22
Would you like to make a pull request or do you prefer for me to assign it to someone else?
msg314915 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2018-04-04 04:24
Also check the 3.7 docs to see if this work has already been done.

It's unlikely that the 3.6 docs will change because it is considered a non-guaranteed implementation detail for 3.6.
History
Date User Action Args
2022-04-11 14:58:59adminsetgithub: 77399
2018-04-04 04:24:58methanesetstatus: open -> closed
superseder: Dict order is now guaranteed, so add tests and doc for it
resolution: duplicate
stage: resolved
2018-04-04 04:24:27rhettingersetmessages: + msg314915
2018-04-04 04:22:51rhettingersetnosy: + rhettinger

messages: + msg314914
versions: - Python 3.6
2018-04-03 20:26:04arjunvcreate