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

Amici Alessandro alessandro_amici at telespazio.it
Tue May 20 09:37:35 EDT 2003


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 :).

cheers,
alessandro



More information about the Gdal-dev mailing list