Newbie question, Does variable need instance after its class modification?
Lee Harr
missive at frontiernet.net
Mon Oct 27 16:06:06 EST 2003
On 2003-10-27, chenyu <chenyu468 at hotmail.com> wrote:
> Hello everyone,
> I am newbie to python programming, then read other's code and try to
> modify for study. My question is as follows:
> 1. class name is "class1", it has one method "method1" and the class
> is in the file "class1.py".
> 2. In the "pythonwin interactive window":
> 2.1 c1 = class1()
> 2.2 cl.method1()
The class instance is called c1, not cl. Try:
c1.method1()
Or, try renaming class1 so it does not have the 1 which is
so easily confused with the l.
> 3. Because I found there is problem in the method1(), therefore I
> modify it by adding "print" statement for debugging in the file
> "class1.py"
> 4. In the "pythonwin interactive window",
> 4.1 c1.method1()
> special ERROR message is given.
Which error might that be?
> 5. In the "pythonwin interactive window",
> 5.1 c1 = class1()
> 5.2 cl.method1()
> The error message disappear, and my debugging information is given.
Just changing your code in class1.py will not affect any
objects already created.
>
> Does it mean that if I modify one file, any variable which instanced
> object from the file is useless and should be instanced again. Is it
> right?
>
You may need to reload() your module to see the changes.
You also should paste a copy of your code and the interactive session
in to your message. What you gave us here is quite confusing.
More information about the Python-list
mailing list