On 13/01/06, Christopher Spears <[EMAIL PROTECTED]> wrote: > I just read about __init__ in the chapter on operator > overloading in Learning Python. What is __init__ > exactly? Is it a special function that you can use to > initialize attributes in an object upon creation?
Pretty much ... Have you read about defining your own classes yet? [I don't have Learning Python] If you haven't, then don't worry about it --- the book will surely cover __init__ when you get to defining classes. But, either way, here is a short example: >>> class MyClass(object): ... def __init__(self): ... print 'Initialising MyClass instance now...' ... self.x = 3 ... >>> m = MyClass() Initialising MyClass instance now... >>> m.x 3 -- John. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor