4 ms·
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
by anitil 2y ago
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.
- sgarland 2y agoIn 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.
- globular-toast 2y agoBut that would be a mistake if you need the branch to run for other falsely values like 0 or the empty string.