[Tutor] __init__

Nicholas Wieland nicholas_wieland@yahoo.it
Thu Feb 27 15:00:02 2003


On 2003.02.27 17:19 vicki@stanfield.net wrote:
> I think I am missing some very basic knowledge with
> regard to my Python/Tkinter programming which is
> preventing me from understanding the examples that I
> find. First the __init__ part, when do I need one? I
> notice that most of the modules that I include contain
> one. Also the example that I am trying to use to make
> my callback (for a Pmw.Entrybox) includes one. Can
> someone point me to some clear definition of what it is
> and when I need it. I apologize for being dense, but I
> can't seem to get past this.

The __init__ method is the constructor of your class, i.e. when you 
make an instance of a class __init__ runs automatically:

class Foo:
   def __init__(self):
     print "Bar"

>>> foo = Foo()
Bar
>>> 

Hope it helps

	Nicholas