[IronPython] Constructors & inheriting from standard .NET classes

Zach Crowell zachc at microsoft.com
Sat Aug 22 01:38:37 CEST 2009


I am unable to inherit from .NET classes which do not define a parameterless constructor.  Is this expected behavior? Is there another way to make this inheritance work?

Here's a simple case.

using System;

namespace Test
{
    public class Base
    {
        public Base(int i)
        {
        }
    }
}

import clr
clr.AddReference('Test')
import Test

class Derived(Test.Base):
    def __init__(self):
        pass

d = Derived()

Traceback (most recent call last):
  File "d:\tmp\class.py", line 9, in d:\tmp\class.py
TypeError: Derived() takes exactly 2 arguments (1 given)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20090821/3d07adca/attachment.html>


More information about the Ironpython-users mailing list