I have a class in Python that has a function that returns a triple (3 information together) and I wanted to create 4 different objects because I need 4 different triples. The point is that the values are accumulating and the 4th object has the information of it and the previous 3 others. Does anyone know why? That is, every time I call the function, the list (global in the class) is not overwritten.
class Anel():
nomeResiduo = ""
numCadeias = 1
centroide = []
def preencheAnel(self, residuo):
i=0
aux = residuo[0][4]
while i < (len(residuo)):
if ((i+1) < len(residuo)):
if(aux != residuo[i+1][4]):
self.numCadeias += 1
aux = residuo[i+1][4]
i=i+1
i = 0
atomosPorCadeia = len(residuo)/self.numCadeias
while i < self.numCadeias:
centroide.append(Anel().calculaCentroide(residuo, self.numCadeias, i))
i += 1
self.nomeResiduo = residuo[0][2]
return (self.nomeResiduo, self.numCadeias, centroide)