filbert
filbert copied to clipboard
Truth value testing
Wasn't sure the right way to title this one. I have a simple function that should only run if the list M is non-empty. I tried to implement it this way:
if M:
a = 10 / len(M)
I get an error as soon as M=[]
This makes the error go away:
if len(M)>0:
a = 10 / len(M)
Nice find! This is because truth value testing is not fully implemented.
https://docs.python.org/3.4/library/stdtypes.html#truth-value-testing
Just noticed #46 is a duplicate of this issue.