I looked at a piece of Python code that I produced, which, although correct, is ugly. Is there a more pythonic way to do this?
r = self.get_pixel(x,y, RED) g = self.get_pixel(x,y, GREEN) b = self.get_pixel(x,y, BLUE) t = function(r,g,b) if t: r2, g2, b2 = t self.set_pixel(x,y,RED, r2) self.set_pixel(x,y,GREEN, g2) self.set_pixel(x,y,BLUE, b2)
The problem is repeating the method call for get_pixel and set_pixel . For information:
RED, GREEN, BLUE = range(3)
Also note that I would like to keep the code clear and clean.
python coding-style
Manuel arΓ‘oz
source share