Yea and then you use "not" with a variable name that does not make it obvious that it is a list and another person who reads the code thinks it is a bool. Hell a couple of months later you yourself wont even understand that it is a list. Moreover "not" will not throw an error if you don't use an sequence/collection there as you should but len will.
You should not sacrifice code readability and safety for over optimization, this is phyton after all I don't think list lengths will be your bottle neck.
I really dislike using boolean operators on anything that is not a boolean. I recently made an esception to my rule and got punished...
Yeah it is skill issue on my part that I tried to check that a variable equal to 0 was not None using "if variable...". But
many programming rules are there to avoid bugs caused by this kind of inattention.
Yea and then you use "not" with a variable name that does not make it obvious that it is a list and another person who reads the code thinks it is a bool. Hell a couple of months later you yourself wont even understand that it is a list. Moreover "not" will not throw an error if you don't use an sequence/collection there as you should but len will.
You should not sacrifice code readability and safety for over optimization, this is phyton after all I don't think list lengths will be your bottle neck.
I really dislike using boolean operators on anything that is not a boolean. I recently made an esception to my rule and got punished... Yeah it is skill issue on my part that I tried to check that a variable equal to 0 was not None using "if variable...". But many programming rules are there to avoid bugs caused by this kind of inattention.