In article <lh7cb4$ntu$2...@news.albasani.net>, Johannes Bauer <dfnsonfsdu...@gmx.de> 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? 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): 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. -- https://mail.python.org/mailman/listinfo/python-list