I'm working on a Python Image Library project for fun. I cannot however, figure out why I keep getting a "list not callable" error for this code:
def __computeTopColors(self):
temp1, temp2, temp3, temp4 = [], [], [], []
max = (0,0,0)
for v in self.PixelVals:
if (v[0] > max[0]) and (v[1] > max[1]) and (v[2] > max[2]):
max = v
min = (1000,1000,1000)
for v in self.PixelVals:
if (v[0] < min[0]) and (v[1] < min[1]) and (v[2] < min[2]):
min = v
for pval in self.PixelVals:
if (min[0] <= pval[0] <= int(((max[0])/2))) and (min[1] <= pval[1] <= int(((max[1])/2))):
temp1.append(pval)
return temp1
def temp(self):
print self.temp
Note: This is actually an excerpt from a class, but I don't think that's particularly relevant. self.PixelVals is a list tuples of the form (R,G,B). self.temp is a temporary method I'm using to test the __computeTopColors method; I set self.temp equal to self.__computeTopColors in __init__.
The Traceback :
Traceback (most recent call last):
File "fiveColors.py", line 39, in <module>
a.temp()
Line 39 is the last line in my code block.
You've shadowed int with a list somewhere. Stop doing that. And stop shadowing min() and max() while you're at it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With