diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py index f316a307c..f183c8f27 100644 --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -557,7 +557,7 @@ def invert(image): :param image: The image to invert. :return: An image. """ - lut = [255 - i for i in range(256)] + lut = list(range(255, -1, -1)) return image.point(lut) if image.mode == "1" else _lut(image, lut) diff --git a/src/PIL/PcfFontFile.py b/src/PIL/PcfFontFile.py index 1f5727eca..8b0014f3a 100644 --- a/src/PIL/PcfFontFile.py +++ b/src/PIL/PcfFontFile.py @@ -129,7 +129,7 @@ class PcfFontFile(FontFile.FontFile): nprops = i32(fp.read(4)) # read property description - p = [(i32(fp.read(4)), i8(fp.read(1)), i32(fp.read(4))) for i in range(nprops)] + p = [(i32(fp.read(4)), i8(fp.read(1)), i32(fp.read(4))) for _ in range(nprops)] if nprops & 3: fp.seek(4 - (nprops & 3), io.SEEK_CUR) # pad diff --git a/src/PIL/SpiderImagePlugin.py b/src/PIL/SpiderImagePlugin.py index 9c06766ff..14cad8f9a 100644 --- a/src/PIL/SpiderImagePlugin.py +++ b/src/PIL/SpiderImagePlugin.py @@ -238,7 +238,7 @@ def makeSpiderHeader(im): if nvalues < 23: return [] - hdr = [0.0 for _ in range(nvalues)] + hdr = [0.0] * nvalues # NB these are Fortran indices hdr[1] = 1.0 # nslice (=1 for an image)