Message329356
Dictionary iterates over keys and this is expected behavior. If you need to iterate by values you should use dict().values()
$ python3 -c 'for i in dict(a=1): print(i)'
a
$ python3 -c 'print(all(dict(a=False)))' # Iterate by keys and thus 'a' is True
True
$ python3 -c 'print(all(dict(a=False).values()))' # Iterate by values explicitly
False
# Relevant PEP section :
https://www.python.org/dev/peps/pep-0234/#dictionary-iterators
> Dictionaries implement a tp_iter slot that returns an efficient iterator that iterates over the keys of the dictionary. During such an iteration, the dictionary should not be modified, except that setting the value for an existing key is allowed (deletions or additions are not, nor is the update() method). This means that we can write
> for k in dict: ...
https://stackoverflow.com/questions/3294889/iterating-over-dictionaries-using-for-loops
This is not a bug but an expected behavior unless I am missing something from the script attached |
|
Date |
User |
Action |
Args |
2018-11-06 13:16:59 | xtreak | set | recipients:
+ xtreak, stnv |
2018-11-06 13:16:59 | xtreak | set | messageid: <1541510219.58.0.788709270274.issue35175@psf.upfronthosting.co.za> |
2018-11-06 13:16:59 | xtreak | link | issue35175 messages |
2018-11-06 13:16:59 | xtreak | create | |
|