[Numpy-discussion] logical_and operator, &&, is missing?
Eric Firing
efiring at hawaii.edu
Sat Jun 24 16:34:35 EDT 2006
Robert Kern wrote:
> Eric Firing wrote:
>
>>It seems that the logical operators || and &&, corresponding to
>>logical_or and logical_and are missing; one can do
>>
>>z = logical_and(x,y)
>>
>>but not
>>
>>z = x && y
>>
>>Is there an inherent reason, or is this a bug?
>
>
> Python does not have a && operator. It has an "and" keyword, but that cannot be
> overridden. If you know x and y to be boolean arrays, & and | work fine.
Out of curiosity, is there a simple explanation as to why "and" cannot
be overridden but operators like "&" can? Is it a fundamental
distinction between operators and keywords?
In any case, it sounds like we are indeed stuck with an unfortunate wart
on numpy, unless some changes in Python can be made. Maybe for
Python3000...
The NumPy for Matlab users wiki is misleading in this area; I will try
to fix it.
Eric
More information about the NumPy-Discussion
mailing list