On 24/10/11 11:17, lina wrote:
<snip>

a quick Q: Every time call the method, need go through the __initi__( ) part?

No.
__init__() is only called when an instance is first created.

Here is an example in the IDLE:

>>> class C:
        def __init__(self):
                print("I'm in init")
        def method(self):
                print("I'm in method")

                
>>> c = C()
I'm in init
>>> c.method()
I'm in method
>>> c2 = C().method()  # calls init for C(), then the method
I'm in init
I'm in method
>>>

HTH,

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to