I want to find how to change a variable via a function that isn’t the one that the variable initiated in using the other function’s argument (to make it viable for many usages).
something along this lines:
class program():
def __init__(self):
...
def change_var(self, variable):
variable = not(variable)
def first_fucn(self):
some_variable = True
print(some_variable) # True
self.change_var(some_variable)
print(some_variable) # False
the problem that it doesn’t only need to change the variable’s value, it need to store that information in the specific variable that I sent through the function.
then you might ask yourself, when didn’t I use return
,
and the answer is it because in my program the function is called through an exterior event – so in short I can’t relay on this solution – I need to make the value and the assignment in the specialized function, and because that the range of variables is a lot, I need a solution that will work every time