filbert icon indicating copy to clipboard operation
filbert copied to clipboard

Truth value testing

Open nemoyatpeace opened this issue 11 years ago • 2 comments

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)

nemoyatpeace avatar Jul 16 '14 00:07 nemoyatpeace

Nice find! This is because truth value testing is not fully implemented.

https://docs.python.org/3.4/library/stdtypes.html#truth-value-testing

differentmatt avatar Jul 16 '14 02:07 differentmatt

Just noticed #46 is a duplicate of this issue.

dideler avatar Dec 26 '14 10:12 dideler