I’m using a .NET library written in c#. Currently I’m running a procedure in IronPython to to call a procedure to create an object like this:
foo = bar.ProcessAndCreateFoo() # bar is a Bar object
The ProcessAndCreateFoo() logs show the method fails in the moment it creates the Foo object; the IronPython console shows the message “‘FooExtended’ is not callable”. Both classes Foo and FooExtended, with the latter being an subclass of the former, are defined inside the class Bar like it’s shown here:
namespace ns.pc
{
public class Bar
{
public class Foo
{
public Foo (Object o)
{
}
}
public class FooExtended : Foo
{
public FooExtended (Object o)
{
}
}
public Foo ProcessAndCreateFoo()
{
// ...
Foo foo = new FooExtended(o);
return foo;
}
}
}
Calling the ProcessAndCreateFoo() method from c# doesn’t throw any errors, only from IronPython. What’s to do to allow the IronPython code execute the function? Which are the corrections to be done to the library, if any?
Try moving each class to its own outer level… as long as in the same namespace, and you already have them public, you can still create them… such as
Now, I’ve left the original Foo an FooExtended as separate as its completely legit to really expand one class to another with more options / features, etc from a baseline. However, what you might have really meant was to overload the creation of a foo object as offered by Richnau.