Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:

It's intended as non-empty strings evaluate to True so you with `'a' and 'b' 
and 'c' in dict` you are essentially evaluating `'a' and 'b' and ('c' in dict)` 
with brackets precedence i.e. `True and True and True` . On the other hand `'a' 
and 'g' and 'c' in dict` it's the same with 'g' evaluated to True. I guess you 
want to check all the keys are present where all is more readable. Some more 
answers here: 
https://stackoverflow.com/questions/1285911/how-do-i-check-that-multiple-keys-are-in-a-dict-in-a-single-pass

>>> all(char in dict for char in ['a', 'b', 'c'])
True
>>> all(char in dict for char in ['a', 'b', 'g'])
False

----------
nosy: +xtreak

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39149>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to