Boolean values: Difference between revisions
Content added Content deleted
(→{{header|Python}}: ++String examples) |
(→{{header|Python}}: None is False.) |
||
Line 60: | Line 60: | ||
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>. |
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>. |
||
None is also <code>False</code> in a boolean context. |
|||
'''Some examples:''' |
'''Some examples:''' |