Dino Viehland wrote: > You are correct in that __new__ methods map to the .NET ctor (both __new__ > and the ctor can only be run once, while __init__ can be called an arbitrary > number of times). Of course someone can construct a type from C# which has > particular __init__ or __new__ semantics but you won't run into that in > Winforms. > > The only interesting thing about not calling __init__ is if multiple > inheritance starts coming into the picture. Then you might want to call your > super's __init__ to ensure everyone gets __init__ run. Unfortunately doing > super(...).__init__ to make this work seems to be questionable as it may open > up its own set of issues. > > But there's certainly no need to Form.__init__. > Thanks Dino.
I think I'll leave it in my examples as it is generally good practise - except in cases of multiple inheritance which is rarely good practise anyway. :-) Michael > ________________________________________ > From: [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf Of Michael Foord [EMAIL > PROTECTED] > Sent: Wednesday, March 14, 2007 4:25 PM > To: Discussion of IronPython > Subject: [IronPython] Initialisation of .NET Subclasses > > Hello all, > > I'm wondering about best practise when subclassing Windows Forms > controls. I have a vague memory of hearing that initialisation is done > in the '__new__' methods of .NET controls, so that '__init__' overrides > *need not* call up to their base class. Is this correct, or was I > hallucinating ? > > In other words, is the following ok : > > class MainForm(Form): > def __init__(self): > pass > > Or should I be doing : > > class MainForm(Form): > def __init__(self): > Form.__init__(self) > > ? > > All the best, > > Michael Foord > http://www.voidspace.org.uk/ironpython/ > _______________________________________________ > users mailing list > [email protected] > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > users mailing list > [email protected] > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > _______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
