[IronPython] How to call a function passing parameters
Fernando Correia
fernandoacorreia at gmail.com
Fri Aug 22 22:31:57 CEST 2008
Please help me to call an IronPython function passing parameters from
a C# method.
Let's say I have a ScriptEngine and also a ScriptScope. In the scope I
have a Python function like this:
def test(a):
return a
Then in some C# method I have something like:
string my_a = "A";
How can I call that function passing to it my_a in place of the "a"
parameter? I want to pass the actual object, not just its value, so I
can pass complex objects and manipulate them in IronPython.
Without passing parameters, I can already do this:
var functionCall = string.Format("{0}()", FunctionName);
ScriptSource function =
engine.CreateScriptSourceFromString(functionCall,
SourceCodeKind.Expression);
function.Execute(scope);
Thanks for any help.
More information about the Ironpython-users
mailing list