News for hackers. Stuff that matters.
Re:Clever code is probably the worst code you could write by anitil on Tuesday May 21, 2024 @11:30PM (#40437037)
In your first example I think most people would skip the 'is not None' as None is already falsy and drop the extra braces.

I find it visually clearer than the second example where the cause and effect are slightly separated, but I do agree there's an element of cleverness to it.

Re:Clever code is probably the worst code you could write by globular-toast on Wednesday May 22, 2024 @03:22AM (#40438225)
But that would be a mistake if you need the branch to run for other falsely values like 0 or the empty string.
Re:Clever code is probably the worst code you could write by sgarland on Wednesday May 22, 2024 @07:30AM (#40439702)
In this imaginary example, yes, a False is likely to cause the same issues that None would. But as a sibling comment mentions, it’s not always desirable to drop the explicitness for syntactic sugar.