[Python-ideas] a bad feature in Python syntax
Chris Angelico
rosuav at gmail.com
Tue Feb 28 22:04:59 EST 2017
On Wed, Mar 1, 2017 at 1:56 PM, 语言破碎处 <mlet_it_bew at 126.com> wrote:
> I'm bited once:
> >>> '' in {} == False
> False
> >>> ('' in {}) == False
> True
>
> # '' in {} == False ==>> ('' in {}) and ({} == False) ==>> False!
>
> I think only compare operations should be chained.
I do feel your pain, but generally, you shouldn't be using "== False"
to negate a condition. That's what the "not" operator is for - or
inverted conditions.
>>> '' not in {}
True
Much better. :)
ChrisA
More information about the Python-ideas
mailing list