I know its not such a pretty thing to have global variables but its only for an exercise my teacher told to do. Its a function to calculate the results of a matrix using jacob. I want to inside the module (inside a function on the module )assign a value to a global variable, but the only way i found to do this inside the own module function is importing the module inside himself. Is there another way of doing this? its kind odd to import the module to himself, i think :-)
here goes the code <============> import lineares_jacob *ERRO_FINAL = 0.0* def obter_respostas(matriz, incognitas, erro_max): erro = erro_max * 10 n = len(matriz) while(erro >= erro_max): novas_incognitas = [] y_um = (2.0 + (1.0 * incognitas[1]) - (1.0 * incognitas[4999])) / 3.0 novas_incognitas.append(y_um) for i in range(1 , (n - 1)): yi = ( (2.0 * i) + incognitas[i - 1] + incognitas[i + 1] ) / (2.0 + i) novas_incognitas.append(yi) y_cinc_mil = (10000.0 - incognitas[0] + incognitas[4998]) / 5002.0 novas_incognitas.append(y_cinc_mil) maior = novas_incognitas[0] - incognitas[0] for i in range(1, 5000): dif = novas_incognitas[i] - incognitas[i] if(dif > maior): maior = dif erro = maior incognitas = novas_incognitas *lineares_jacob.ERRO_FINAL = erro* return incognitas _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor