Newbie question, Does variable need instance after its class modification?

C

chenyu

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()
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.
5. In the "pythonwin interactive window",
5.1 c1 = class1()
5.2 cl.method1()
The error message disappear, and my debugging information is given.

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?



Thank you in advance.
kind regards/chenyu
 
L

Lee Harr

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,001
Messages
2,570,255
Members
46,852
Latest member
CarlaDowle

Latest Threads

Top