Anonymous user
Boolean values: Difference between revisions
→{{header|Python}}: ++String examples
(→{{header|Python}}: Consolidation.) |
(→{{header|Python}}: ++String examples) |
||
Line 61:
A user-created class that defines a <tt>.__nonzero__()</tt> method to return False, or whose <tt>.__len__()</tt> method returns 0 will be treated as <code>False</code>, otherwise the class/instance is treated as <code>True</code>.
'''Some examples:'''
<lang python>>>> True
True
Line 97:
>>> bool({})
False
>>> bool("")
False
>>> bool("False")
True
>>> </lang>
|