Hello everyone,<br><br>I am fairly new to Python and occasionally run into problems that are almost always resolved by referring to this mailing-list's archives. However, I have this one issue which has got me stuck and I hope you will be tolerant enough to help em out with it!<br>
<br>What I want to achieve is something like the global variables in C/C++: you declare them in one file and "extern" them in all the files where you need to use them. I have 3 files: one.py, two.py and three.py as below:<br>
<br>one.py<br>----------<br>a = 'place_a'<br>b = 'place_b'<br>x = 'place_x'<br><br>myList = [a, b, 'place_c']<br><br>======================================================================<br>
<br>two.py<br>----------<br>import one<br><br>def myFunc():<br> print one.x<br> print one.myList<br><br>======================================================================<br><br>three.py<br>------------<br>import one<br>
import two<br><br>def argFunc():<br> one.x = 'place_no_x'<br> one.a = 'place_no_a'<br> one.b = 'place_no_b'<br><br>if __name__ == '__main__':<br> two.myFunc()<br> print<br> argFunc()<br>
two.myFunc()<br><br>======================================================================<br><br>Output:<br>-----------<br>'place_x'<br>['place_a', 'place_b', 'place_c']<br><br>'place_no_x'<br>
['place_a', 'place_b', 'place_c'] (*** instead of ['place_no_a', 'place_no_b', 'place_c'] ***)<br><br>The last line in the output is what's baffling me. Can anyone please help me know if I am doing something wrong?<br>
<br>Thanks in advance,<br>Nitin.<br>