differentmatt / filbert

JavaScript parser of Python
Other
133 stars 27 forks source link

Truth value testing #27

Open nemoyatpeace opened 10 years ago

nemoyatpeace commented 10 years ago

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)
differentmatt commented 10 years ago

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

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

dideler commented 9 years ago

Just noticed #46 is a duplicate of this issue.