Member-only story
6 Boolean Things I’ve Observed In Production Python Code
I’ve worked as a software engineer at 3 multinational companies thus far, and have observed lots of good (and bad) practices in Python. Here are some common observations I’ve made about booleans:
1) bool() is explicitly used sometimes
In production code, readability is often a prioritized and some programmers choose to write code more explicitly.
Here’s an example of how we might normally write our conditions:
However, when we have a whole bunch of conditions, I’ve seen some cases where bool()
is explicitly used to make the code more readable.
Arguably, removing the bool()
won’t affect the result of the code at all. But it does make it more immediately obvious that the entire condition should be a boolean value