3 ms·
Python code rarely looks like this For things like optional arguments you usually use None with an "if l is None" parameter Meanwhile you can't iterate over
by rtpg 8y ago
Python code rarely looks like this
For things like optional arguments you usually use None with an "if l is None" parameter
Meanwhile you can't iterate over None, so [x for x in None] blows up
Closure (to my understanding) allows a null value in the place of any empty seq. This seems like a major bug swallower to me
- yen223 8y ago> Python code rarely looks like this Using implicit truthiness to test for empty sequences is idiomatic Python, for better or worse.
- rtpg 8y agoSorry, you're actually very right. I think I misread this in the case of a default argument example (which at least for codebases I work with are diligent about doing None tests for ) but if you know that the value is set to a sequence then the boolean test is common