I have a main python file and a class in a different python file. I have tried to change a variable in the python file from the class. However, I don't know how to do this outside of the __init__ function.
The class:
class Matrices:
currentMenuItem = 0
dataForMatrix = {}
def __init__(self, memory, matricesFrame, tempBoolsControl, otherControls):
self.memory = memory
self.matricesFrame = matricesFrame
self.tempBoolsControl = tempBoolsControl
self.otherControls = otherControls
def createNewMatrix(self):
self.otherControls["right"] = False
The main file:
from Matrices import Matrices
otherControls = {"right": True, "left": True}
Matrices(memory, matricesFrame, tempBoolsControl, otherControls).createNewMatrix()
This is meant to change the otherControls variable in the main file, but it only changes it locally. I can't access the original otherControls variable outside of the __init__ function. Can anyone help?
othercontrols!= class attributeself.othercontrols