[Tutor] What is the difference between checking false?
eryksun
eryksun at gmail.com
Sun Jun 16 04:45:14 CEST 2013
On Sat, Jun 15, 2013 at 10:23 PM, eryksun <eryksun at gmail.com> wrote:
> This function is hard coded for the singletons True,
> False, and None -- and otherwise uses either __bool__
> (tp_as_number->nb_bool) or __len__ (tp_as_mapping->mp_length or
> tp_as_sequence->sq_length). A length of 0 is falsey.
I forgot to add that 2.x uses the special method __nonzero__ instead
of __bool__. This can return either an int or a bool. In Python 3
__bool__ can only return a bool.
More information about the Tutor
mailing list