Message314892
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}
``` |
|
Date |
User |
Action |
Args |
2018-04-03 20:26:04 | arjunv | set | recipients:
+ arjunv, docs@python |
2018-04-03 20:26:04 | arjunv | set | messageid: <1522787164.53.0.467229070634.issue33218@psf.upfronthosting.co.za> |
2018-04-03 20:26:04 | arjunv | link | issue33218 messages |
2018-04-03 20:26:04 | arjunv | create | |
|