[Numpy-discussion] logical_and operator, &&, is missing?
Robert Kern
robert.kern at gmail.com
Sat Jun 24 16:20:43 EDT 2006
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.
> z = (x == y)
>
> works, and a comment in umathmodule.c.src suggests that && and || should
> also:
>
> /**begin repeat
>
> #kind=greater, greater_equal, less, less_equal, equal, not_equal,
> logical_and, logical_or, bitwise_and, bitwise_or, bitwise_xor#
> #OP=>, >=, <, <=, ==, !=, &&, ||, &, |, ^#
> **/
Those operators are the C versions that will be put in the appropriate places in
the generated code. That is not a comment for documentation.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion
mailing list