On Jul 27, 2007, at 10:56 PM, Gary Herron wrote: > The variable "value" is global in module_a, and "change_value" will > always refer to that variable. > > However, in module_b, when you from module_a import value, > change_value > you have created two new variables global to module_b that references > values from the other module. > Now running change_value (which changes "value" in module_a has no > affect on the version of "value" in module_b. Your print is then > printing value from module_b -- the unchanged version.
Thank you, Gary, but I still have one question. What happens in the second case? If I add a call to change_value() to module_a, the value in module_b is imported changed. Why? What exactly does the import statement import in my example? > Ideas: > 1 If you want module_a to manage such a global variable, you could > include functions for getting, and setting it, as well as your > function for changing it's value. > > 2. You could also dispense with use of global values -- various OOP > techniques could help there. Thanks, this part is not a problem :) Cheers, Valia -- http://mail.python.org/mailman/listinfo/python-list