[IronPython] How to call a specific base class constructor?
Dino Viehland
dinov at exchange.microsoft.com
Fri Sep 22 22:02:14 CEST 2006
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: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ruxo Zheng
Sent: Wednesday, September 20, 2006 12:39 PM
To: users at lists.ironpython.com
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060922/0b43105d/attachment.html>
More information about the Ironpython-users
mailing list