[Numpy-discussion] truthiness of object arrays
Charles R Harris
charlesr.harris at gmail.com
Fri Nov 14 11:15:11 EST 2014
On Thu, Nov 13, 2014 at 8:24 AM, Alan G Isaac <alan.isaac at gmail.com> wrote:
> On 11/13/2014 1:19 AM, Antony Lee wrote:
> > "t.__bool__()" also returns True
> But t.__nonzero__() is being called in the `if` test.
> The question is: is the difference between `__nonzero__`
> and `__bool__` intentional.
> By the way, there has been a change in behavior.
> For example, in 1.7.1 if you call `t.__bool__()`
> it raised an attribute error -- unless one first
> called `t.__nonzero__()` and then called `t.__bool__()`,
> which was of course very weird and needed to be fixed.
> Maybe (?) not like this.
The change probably came in with the Python2/3 common code base. Python3
replaces `__nonzero__` with `__bool__`. IIRC, the two are now the same
method. I don't have the code available to check...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion