2 ms·
It depends. If you're checking to see if that value is None, then yes - you should check that. If you're merely checking if the value is truthy, then using "i
by LyndsySimon 12y ago
It depends.
If you're checking to see if that value is None, then yes - you should check that.
If you're merely checking if the value is truthy, then using "if x:" is completely legitimate.
- pyfish 12y agoI agree. The author brings this to light as well and warns about the implications of changing what is considered "truthy" in x.
- keeperofdakeys 12y agoI've found "if x" to be much less readable, especially when I'm looking at code written in a language I'm not familiar with. When I'm reading such code, I want to be 100% what something is doing, and not have to read documentation when avoidable.