[IronPython] IPy embedding problem

Igor Elyas igor_elyas at hotmail.com
Sun Mar 15 17:35:21 CET 2009


Hello

This sample code throws error on Python object initialization:

            var engine = Python.CreateEngine();
            var Ops = engine.CreateOperations();
            engine.Runtime.LoadAssembly(typeof(Decimal).Assembly);
            var src =
                @"
class Checker:
  def __init__(self, one, two, three=''):
    self.one = one
    self.two = two
    self.tree = three
  def Call(self):
    return self.one + self.two + self.tree
";

            var cs = engine.CreateScriptSourceFromString(src, SourceCodeKind.Statements).Compile();
            cs.Execute();
            var tclass = cs.DefaultScope.GetVariable("Checker");
            object obj = cs.Engine.Operations.Call(tclass,"one","two","three");// throw NotImplementedException

            Console.WriteLine(obj);

But if I use only 2 parameter in initialize/constructor such as :

           object obj = cs.Engine.Operations.Call(tclass,"one","two");

, than all works fine. 

What wrong ?

Best regards
Igor Elyas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20090315/1bdb9ff5/attachment.html>


More information about the Ironpython-users mailing list