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.

Author xtreak
Recipients stnv, xtreak
Date 2018-11-06.13:16:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1541510219.58.0.788709270274.issue35175@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2018-11-06 13:16:59xtreaksetrecipients: + xtreak, stnv
2018-11-06 13:16:59xtreaksetmessageid: <1541510219.58.0.788709270274.issue35175@psf.upfronthosting.co.za>
2018-11-06 13:16:59xtreaklinkissue35175 messages
2018-11-06 13:16:59xtreakcreate