C
chandan kumar
Hi ,
I'm trying to understand using global variable across different modules.Here is what i have tried so far without much success.Please ignore any indentation issue in the below code.
Filename:Test1.py
Debug_Value = " "
import Test2
def globalValmethod():
global Debug_Value
Debug_Value =10
Test2.globalValTest()
globalValmethod() -----Execute the method
Filename:Test2.py
import Test1
from Test1 import *
def globalValTest()
print "Golabal Value" Debug_Value
In Test2.py file I wanted to print the global value ,Debug_Value as 10.I'm not getting expected result.Please can any one point where exactly i'm doing wrong.
Similarly , how can i use global variable inside a class and use the same value of global variable in different class?Is that possible?if Yes please give me some pointers on implementing.
Best Regards,
Chandan
I'm trying to understand using global variable across different modules.Here is what i have tried so far without much success.Please ignore any indentation issue in the below code.
Filename:Test1.py
Debug_Value = " "
import Test2
def globalValmethod():
global Debug_Value
Debug_Value =10
Test2.globalValTest()
globalValmethod() -----Execute the method
Filename:Test2.py
import Test1
from Test1 import *
def globalValTest()
print "Golabal Value" Debug_Value
In Test2.py file I wanted to print the global value ,Debug_Value as 10.I'm not getting expected result.Please can any one point where exactly i'm doing wrong.
Similarly , how can i use global variable inside a class and use the same value of global variable in different class?Is that possible?if Yes please give me some pointers on implementing.
Best Regards,
Chandan