I want to make it so x is only global within the class.
I have tried using self.x but that does not seem to work. I could be doing it wrong though.
class Test:
def __init__(self):
pass
def test1(self,number):
global x
x = number
print(x)
def whereIwantToRedefineIt(self):
print(x)
Test().test1(2) #<------ Making output 2
x=200 #<-------------- It should not be able to redefine the variable
Test().whereIwantToRedefineIt() #<-------- I want to make this output 2
I want to make the function "whereIwantToRedefineIt" not be affected by the "x=200" which is outside the class. I want it to output 2