Hello, I do not know if this question has already been answered, but my problem is this:
When assigning a global variable to a local variable of a class, changing the value of the local variable also modifies the value of the global variable. Below I attach the code.
import numpy as np
x = np.zeros((3, 3))
x[1][1] = 1
class MyApp(QtWidgets.QMainWindow):
def _func_1_(self):
global x
print("x[1][1] =", x[1][1]) # Primera Salida
self.aux = x
self.aux[1][1] = _func_2_(aux[1][1])
print("x[1][1] =", x[1][1]) # Segunda Salida
def _func_2_(self, value):
return (value * 10)
$ x[1][1] = 1
$ x[1][1] = 10
As you can see in the output of the code, before performing the operation on the aux matrix the value of x [1] [1] = 1 , while after the operation that of x [1] [1] = 10 .
What can the code failure be?
Thank you very much.