March 2003
Intermediate to advanced
656 pages
39h 30m
English
__nonzero__
__nonzero__(self)
When evaluating x as true or false (see Section 4.2.6), for example on a call to
bool(
x
)
in Python 2.2.1 and later, Python calls
x
.__nonzero__( ),
which should return True or
False. When __nonzero__ is
not present, Python calls __len__ instead, and
takes x as false when
x
.__len__( ) returns
0. When neither __nonzero__
nor __len__ is present, Python always takes
x as true.