Tag

none-check

1 views collected around this technical thread.

Python Programming Learning Circle
Python Programming Learning Circle
Feb 5, 2020 · Fundamentals

Why ‘if x is not None’ Beats ‘if not x’ in Python: Avoid Hidden Bugs

This article explains the three common ways to test for None in Python, reveals how using "if not x" can mistakenly treat other falsy values as None, and recommends the clear and safe "if x is not None" style endorsed by Google.

best-practicescode styleconditional
0 likes · 3 min read
Why ‘if x is not None’ Beats ‘if not x’ in Python: Avoid Hidden Bugs