Or you could say
if my_list == :
I've never understood the one way is more pythonic than another thing
That's another good one! I'll add it to the list.
The term Pythonic is a little ambiguous to be honest, but I like to think that it sums up one of the core ideas of Python which is "there is only one way to do it." In other words, the Python developers try to avoid including unnecessary complexity in the language by enforcing a certain problem solving style. As a result, you won't find switch statements or c-style for loops in Python.
As a bonus, choosing the Pythonic solution (i.e. testing emptiness by type flexibility) is usually the cleanest and most optimized solution. Of course, that comes with a caveat: Pythonic solutions are not always readable solutions.
We’re a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.