global variable across modules

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top