diff --git a/PIL/ImageMorph.py b/PIL/ImageMorph.py index 4847594f6..748ecdb61 100644 --- a/PIL/ImageMorph.py +++ b/PIL/ImageMorph.py @@ -156,10 +156,10 @@ class LutBuilder(object): # print '--' # compile the patterns into regular expressions for speed - for i in range(len(patterns)): - p = patterns[i][0].replace('.', 'X').replace('X', '[01]') + for i, pattern in enumerate(patterns): + p = pattern[0].replace('.', 'X').replace('X', '[01]') p = re.compile(p) - patterns[i] = (p, patterns[i][1]) + patterns[i] = (p, pattern[1]) # Step through table and find patterns that match. # Note that all the patterns are searched. The last one diff --git a/PIL/PalmImagePlugin.py b/PIL/PalmImagePlugin.py index 4f415ff7c..d02839bdf 100644 --- a/PIL/PalmImagePlugin.py +++ b/PIL/PalmImagePlugin.py @@ -80,13 +80,12 @@ _Palm8BitColormapValues = ( # so build a prototype image to be used for palette resampling def build_prototype_image(): - image = Image.new("L", (1, len(_Palm8BitColormapValues),)) + image = Image.new("L", (1, len(_Palm8BitColormapValues))) image.putdata(list(range(len(_Palm8BitColormapValues)))) palettedata = () - for i in range(len(_Palm8BitColormapValues)): - palettedata = palettedata + _Palm8BitColormapValues[i] - for i in range(256 - len(_Palm8BitColormapValues)): - palettedata = palettedata + (0, 0, 0) + for colormapValue in _Palm8BitColormapValues: + palettedata += colormapValue + palettedata += (0, 0, 0)*(256 - len(_Palm8BitColormapValues)) image.putpalette(palettedata) return image diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py index 3af38832d..52e04654c 100644 --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -1246,12 +1246,12 @@ class TiffImageFile(ImageFile.ImageFile): a = None else: - for i in range(len(offsets)): + for i, offset in enumerate(offsets): a = self._decoder(rawmode, l, i) self.tile.append( (self._compression, (0, min(y, ysize), w, min(y+h, ysize)), - offsets[i], a)) + offset, a)) if DEBUG: print("tiles: ", self.tile) y = y + h