[Numpy-discussion] logical priority

Stephen Walton stephen.walton at csun.edu
Mon Feb 7 14:30:25 CST 2005


konrad.hinsen at laposte.net wrote:

> Operator priorities are part of the Python language and implemented 
> in  the parser. Numarray cannot interfere with that.

In Python, of course, & is a bitwise AND, logical and being the literal 
word "and".  & has lower operator priority than <, but "and" has a 
higher one.

I think the real problem is that "and" doesn't work on numarray bool 
arrays in an element-wise fashion as I expected;  perhaps it should?  
Otherwise constructs like

v = A>10 and A<15

have to be written as

v1=A>10; v2=A<15; v=v1&v2

or as
v = (A>10) & (A<15)





More information about the Numpy-discussion mailing list