[Gdal-dev] gdal.py: operand precedence bug

Frank Warmerdam warmerdam at pobox.com
Tue May 20 10:31:10 EDT 2003


Amici Alessandro wrote:
> Frank,
> 
> in gdal.py line 347:
> 
> def GetRasterBand(self, i):
>     if i > 0 & i <= self.RasterCount:
> 
> should read as:
> 
> def GetRasterBand(self, i):
>     if i > 0 and i <= self.RasterCount:
> 
> or, in a more pythonic style, as:
> def GetRasterBand(self, i):
>     if 0 < i <= self.RasterCount:
> 
> in fact, due to the relative precedence, the first form is
> evaluated as:
>     i > (0 & i) <= self.Rastercount
> which is valid python syntax, but obviously not the intended
> behavior.
> 
> it seems overkill to me, but if you want i can file a bug report :).

Alessandro,

fix committed.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent





More information about the Gdal-dev mailing list