Eval of expr with 'or' and 'and' within

MRAB python at mrabarnett.plus.com
Fri Jun 14 20:26:42 EDT 2013


On 15/06/2013 00:06, Nobody wrote:
> On Fri, 14 Jun 2013 16:49:11 +0000, Steven D'Aprano wrote:
>
>> Unlike Javascript though, Python's idea of truthy and falsey is actually
>> quite consistent:
>
> Beyond that, if a user-defined type implements a __nonzero__() method then
> it determines whether an instance is true or false. If it implements a
> __len__() method, then an instance is true if it has a non-zero length.
>
It's __nonzero__ in Python 2, __bool__ in Python 3.



More information about the Python-list mailing list