checking if two things do not equal None

Johannes Bauer dfnsonfsduifb at gmx.de
Sat Mar 29 17:01:24 EDT 2014


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?

Cheers,
Johannes

-- 
>> Wo hattest Du das Beben nochmal GENAU vorhergesagt?
> Zumindest nicht öffentlich!
Ah, der neueste und bis heute genialste Streich unsere großen
Kosmologen: Die Geheim-Vorhersage.
 - Karl Kaos über Rüdiger Thomas in dsa <hidbv3$om2$1 at speranza.aioe.org>



More information about the Python-list mailing list