Another OOP question.

SA sarmstrong13 at mac.com
Sun May 26 00:34:38 EDT 2002


The following is an example class from a tutorial:

class Message:
    def __init__(self, aString):
        self.text = aString
    def printIt(self):
        print self.text

Let me see if I am understanding the structure correctly. __init__ is used
first to initialize the class. Self refers to the class. Astring is the
variable passed to the class from code outside the class. PrintIt is called
from outside code to print the variable loaded in the class.

Ok. Given that this is an overly simplistic explanation, is this the correct
interpretation of this class?

Thanks. I hope I'm finally getting OOP.

SA




More information about the Python-list mailing list