Day 392
Python truthy and falsy
TIL that values considered true/false without being explicitly True/False have a name, and from python - What is Truthy and Falsy? How is it different from True and False? - Stack Overflow here’s a handy list of them:
All values are considered “truthy” except for the following, which are “falsy”:
NoneFalse00.00jDecimal(0)Fraction(0, 1)[]- an emptylist{}- an emptydict()- an emptytuple''- an emptystrb''- an emptybytesset()- an emptyset- an empty
range, likerange(0) - objects for which
obj.__bool__()returnsFalseobj.__len__()returns0
A “truthy” value will satisfy the check performed by if or while statements. We use “truthy” and “falsy” to differentiate from the bool values True and False.
Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus