3 ms·
Meanwhile in Python land, this is not a common class of bugs even though this implicit boolification happens.
by toxik 4y ago
Meanwhile in Python land, this is not a common class of bugs even though this implicit boolification happens.
- lostmsu 4y agoMy only explanation for that may be because Python has more severe and commonly occuring issues?
- cma 4y agoI've been bitten by it in Python. It isn't quite up there with PHP style weak typing combining int and string with + but feels similar, even if you can make some modulo 2 arithmetic argument that it should work like other mixed precision stuff.
- cjbprime 4y agoI wrote a (len(foo == 0)) instead of (len(foo) == 0) in Python yesterday. I don't understand why you would say this.
- toxik 4y ago… which is exactly what you don’t need to do in Python, because that is just `if foo`, thus sidestepping the issue
- mr_00ff00 4y agoLol python is the king of these types of errors. People chose the unsafe because it’s easy when we know types are one of the best tools engineers can have.
- diarrhea 4y agoStatic typing is orthogonal to this issue though. This is more about strong typing. Even a statically typed language could coerce values, e.g. the empty string, to a Boolean false at runtime. I agree that that’s undesirable though. Static and strong typing is the driest, least flexible, but also easiest to get correct way.