[New-bugs-announce] [issue33218] Fix instances in documentation where dictionaries are referenced as unordered

arjun v report at bugs.python.org
Tue Apr 3 16:26:04 EDT 2018


New submission from arjun v <arjunvkp at gmail.com>:

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}
```

----------
assignee: docs at python
components: Documentation
messages: 314892
nosy: arjunv, docs at python
priority: normal
severity: normal
status: open
title: Fix instances in documentation where dictionaries are referenced as unordered
versions: Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33218>
_______________________________________


More information about the New-bugs-announce mailing list