4 ms·
Because if something can return None, you should explicitly check for that, to avoid truthy/falsy gotchas [1]. [1] https://www.inspiredpython.com/article/truth
by mickeyp 3y ago
Because if something can return None, you should explicitly check for that, to avoid truthy/falsy gotchas [1].
[1] https://www.inspiredpython.com/article/truthy-and-falsy-gotchas https://www.inspiredpython.com/article/truthy-and-falsy-gotc...
- PurpleRamen 3y agoNo, you should not. Checking for None is relevant when you care about the case where it's important. But that doesn't mean every case is one. In the example here, all we care is if we can do something, and everything else doesn't matter. Which is also the reason why I could shortened credit from two checks to one.