I was surprised to discover that "X in Y is not None" does not throw an exception. I can't figure out how Python actually interprets this. What value does "is not None" operate on? Does it serve any purpose here?
>>> "asdf" in {} is not None
False
>>>
>>> "asdf" in {"asdf": 1} is not None
True
>>>
Python comparison chaining strikes again.
According to the same rules that says that 1 < 2 < 3 is equivalent to 1 < 2 and 2 < 3, these expressions:
"asdf" in {} is not None
"asdf" in {"asdf": 1} is not None
Are equivalent to:
"asdf" in {} and {} is not None
"asdf" in {"asdf": 1} and {"asdf": 1} is not None
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With