Friday 4 December 2015

Python: What values represent True

Following values are considered False.
a.   None
b.   False
c.    Zero of any numeric type, like 0, 0.0, 0j
d.   Any empty sequences like [], (), ‘’
e.   Any empty mappings like {}
f.     If user defined class defines a __bool__() or __len__() method, when that method returns the integer zero or bool value False.
Remaining all values considered to be True values.



Previous                                                 Next                                                 Home

No comments:

Post a Comment