checking if two things do not equal None

Johannes Bauer dfnsonfsduifb at
Sat Mar 29 22:55:12 CET 2014

On 29.03.2014 22:07, Roy Smith wrote:

> I agree with that.  But
>> if (a, b) != (None, None):
> seems pretty straight-forward to me too.  In fact, if anything, it seems 
> easier to understand than
>> if (a is not None) or (b is not None):

Yes, probably. I liked the original, too. If I were writing the code,
I'd probably try to aim to invert the condition though and simply do

if (a is None) and (b is None)

Which is pretty easy to understand for even a rookie programmer.

> I certainly agree that things like
>> if a is not b is not None: ...
> belong in an obfuscated coding contest.  Code gets read a lot more often 
> than it get written.  Make it dead-ass simple to understand, and future 
> generations of programmers who inherit your code will thank you for it.



>> 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>

More information about the Python-list mailing list