[Numpy-discussion] logical_and operator, &&, is missing?
robert.kern at gmail.com
Sat Jun 24 16:32:16 CDT 2006
Eric Firing wrote:
> That makes sense, and implies that the real solution would be the
> introduction of operators && and || into Python, or a facility that
> would allow extensions to add operators. I guess it would be a matter
> of having hooks into the parser. I have no idea whether either of these
> is a reasonable goal--but it certainly would be a big plus for Numpy.
I don't really see how. We already have the & and | operators. The only
difference between them and the && and || operators would be that the latter
would automatically coerce to boolean arrays. But you can do that explicitly, now.
a.astype(bool) | b.astype(bool)
Of course, it's highly likely that you are applying & and | to arrays that are
already boolean. Consequently, I don't see a real need for more operators.
But if you'd like to play around with the grammar:
"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