logical statements (in Python and Numeric)

Chris Barker Chris.Barker at noaa.gov
Thu Jun 20 17:41:54 EDT 2002


Fernando Pérez wrote:
> Are you sure? This is what I get:
> 
> In [11]: x = arrayrange(-4.,2.+.001,.001, Float)
> 
> In [12]: x >= -2. & x < 0.
> ---------------------------------------------------------------------------
> TypeError                                 Traceback (most recent call last)
> 
> ?
> 
> TypeError: unsupported operand type(s) for &: 'float' and 'float'

oops, that's what I get for posting untested code. You need parentheses,
the above was trying to bitwise-and -2.0 and x

(x >= -2.) & (x < 0.)
works.

-Chris

-- 
Christopher Barker, Ph.D.
Oceanographer
                                    		
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov



More information about the Python-list mailing list