checking if two things do not equal None

Ethan Furman ethan at stoneleaf.us
Sat Mar 29 19:20:40 EDT 2014


On 03/29/2014 02:01 PM, Johannes Bauer wrote:
> On 29.03.2014 20:05, Steven D'Aprano wrote:
>> 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?
>>
>> if not (a is b is None): ...
>>
>> Or if you prefer:
>>
>> if a is not b is not None: ...
>
> Is this an obfuscated coding contest? Why do you opt for a solution that
> one has to at least think 2 seconds about when the simplest solution:
>
> if (a is not None) or (b is not None):
>
> is immediately understandable by everyone?

+1

--
~Ethan~



More information about the Python-list mailing list