Re: [Tutor] Using superclass __init__ method

2005-09-22 Thread Jan Eden
Hi, paul brian wrote on 22.09.2005: > >class Base: > def __init__(self): > print "hello" > >class Child(Base): > def __init__(self): > Base.__init__(self) > This is how I did it so far. But in my program, I have 10 subclasses with identical __init__ methods, so I can simplify th

Re: [Tutor] Using superclass __init__ method

2005-09-22 Thread Jan Eden
Kent Johnson wrote on 22.09.2005: >This is standard behavior for any class attribute - if it's not >defined in the derived class, the base class is checked. It's not >special for __init__. > >I can't find a comprehensive reference for the way attribute lookup >works - anyone else? Well, I did kno

Re: [Tutor] Using superclass __init__ method

2005-09-22 Thread paul brian
There are several areas this seems to touch upon, most of them well covered by Guido himself in http://www.python.org/2.2/descrintro.html firstly to call a super class' methods you get the subclass to refer to the *superclass* then the method (note not to the superclass instance) from newstyle tu

Re: [Tutor] Using superclass __init__ method

2005-09-22 Thread Kent Johnson
Jan Eden wrote: > Hi, > > I just noticed that in the following environment: > > class Base: > def __init__(self): > ... > > class Child(Base): > pass > > the following statement: > > child = Child() > > would automatically execute the superclass __init__ method. This is ex

[Tutor] Using superclass __init__ method

2005-09-22 Thread Jan Eden
Hi, I just noticed that in the following environment: class Base: def __init__(self): ... class Child(Base): pass the following statement: child = Child() would automatically execute the superclass __init__ method. This is exactly what I was looking for - but in the Cookb