I am hosting iron python I my C# app and I’m running into problems calling python methods.  For example given the following script:

 

(in MethodTest.py)

 

def Method1():

    return 5

 

def Method2():

    return 10

 

and the following C# code:

 

PythonEngine pe = new PythonEngine();

pe.ExecuteFile("MethodTest.py");

 

Console.WriteLine(pe.Evaluate("1+1"));

Console.WriteLine(pe.Evaluate("Method1()"));

Console.WriteLine(pe.Evaluate("Method2()"));

 

I would expect the following output:

2

5

10

 

But I actually get:

2

5

5

 

I fould out that when I call “Method2()” it actually just calls the first method in the py file…so changing MethodTest.py to:

 

def Method2():

    return 10

 

def Method1():

    return 5

 

then I get the output of:

2

10

10

 

This is basically a show stopper for me because I need the user to be able to define more than one function which I call from C#.

 

Any suggestions?

 

-Brandon Furtwangler

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

Reply via email to