checking if two things do not equal None
steve+comp.lang.python at pearwood.info
Sat Mar 29 20:05:03 CET 2014
On Sat, 29 Mar 2014 11:56:50 -0700, contact.trigon wrote:
> if (a, b) != (None, None):
> if a != None != b:
> Preference? Pros? Cons? Alternatives?
Do you actually want to check for arbitrary objects which may claim to
equal None, or do you want to check for objects which are None?
Nearly always when people test for == to None, they don't really mean it.
They actually want to use an identity test. I'm going to assume the same
if not (a is b is None): ...
Or if you prefer:
if a is not b is not None: ...
More information about the Python-list