The constructor is actually __new__, __init__ is merely an initializer which runs after constructor – which has no real analog in the .NET world.  Therefore you’ll want to override __new__ and pass in the values to the base __new__ that you want to use to construct the object with.

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ruxo Zheng
Sent: Wednesday, September 20, 2006 12:39 PM
To: [email protected]
Subject: [IronPython] How to call a specific base class constructor?

 

I'm customizing .NET ArrayList class like this:

from System.Collections import ArrayList

class MyArrayList(ArrayList):
    def __init__(self):
       ArrayList.__init__(self, 256)

test = MyArrayList()
test.Capacity  // return 0

It seems like default constructor is always called.   Did I incorrectly call the base class' constructor?


Rux

_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to