New submission from Leonardo Galani <l...@leonardobg.com.br>:

using Python 3.7.6 (default, Dec 27 2019, 09:51:07) @ macOs

dict = { 'a': 1, 'b': 2, 'c': 3 }

if you `if 'a' and 'b' and 'c' in dict: print('ok')` you will get a True, since 
everything is true.

if you `if 'a' and 'g' and 'c' in dict: print('ok')` you also get a True 
because the last statement is True but the mid statement is false.

To avoid this false positive, you need to be explicit:
`if 'a' in dict and 'g' in dict and 'c' in dict: print('ok')` you will get a 
false.

----------
components: macOS
messages: 358954
nosy: leonardogalani, ned.deily, ronaldoussoren
priority: normal
severity: normal
status: open
title: False positive using operator 'AND' while checking keys on dict()
versions: Python 3.7

_______________________________________
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