Problem with imported variable

Chris Barker chrishbarker at home.net
Thu Nov 1 14:28:22 EST 2001


carole valentin wrote:
> I have a little question:
> I have 2 classes "Class1" and "Class2" and several
> functions in each class. The Class1 is in the file
> "File1" and the Class2 is in another file "File2". At
> the beginning of the File1, I import the File2:
> from File2 import *
> 
> In the Class2, I create a variable with a specific
> value. When the program is running, I modify the value
> of this variable in the other class (Class1) and then
> I want to read the new value of the variable farther
> in the code of the Class2.
> The problem is that the value does not change in the
> File2 (Class2). Moreover, as the 2 classes are not in
> the same files, the global statement does not change
> the problem.
> Does someone have an idea?
> Thanks for your help!

Someone else may be able to figure out what you want to do, but I'm
lost. Try posting a very small version of your attempt to do what you
want, and we'll probably be able to help you.

One question: when you say "I modify the value of this variable in the
other class (Class1) and then I want to read the new value of the
variable farther in the code of the Class2" are you talking about
changing a class variable or an instance variable?

-Chris



-- 
Christopher Barker,
Ph.D.                                                           
ChrisHBarker at home.net                 ---           ---           ---
http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                   ------@@@     ------@@@     ------@@@
Oil Spill Modeling                ------   @    ------   @   ------   @
Water Resources Engineering       -------      ---------     --------    
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------



More information about the Python-list mailing list