On Sat, 29 Mar 2014 11:56:50 -0700, contact.trigon wrote:

> if (a, b) != (None, None):
> or
> 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 
holds here.

if not (a is b is None): ...


Or if you prefer:

if a is not b is not None: ...




-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to