Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53957

global variable across modules

Date 2013-09-11 20:50 +0800
From chandan kumar <chandan_psr@yahoo.co.in>
Subject global variable across modules
Newsgroups comp.lang.python
Message-ID <mailman.247.1378903988.5461.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

global variable across modules chandan kumar <chandan_psr@yahoo.co.in> - 2013-09-11 20:50 +0800

csiph-web