[IronPython] Update from IronPython v1.0 to IronPython v2.6
Evan WANG
wmrj76 at motorola.com
Thu Mar 25 09:27:49 CET 2010
Hi IronPython experts,
I am a newcomers in the IronPython, I am working on update the IronPython
engine in our c# project.
After studied some days from all of your articles, I still have one question
can't be fixed.
In IronPython v1.0, we use the below code to call a function in the .py file
this.pythonEngine = new PythonEngine();
// Load the script
this.pythonEngine.ExecuteFile(@filePath);
string address;
address = this.pythonEngine.Evaluate("GetScriptInfo").ToString();
How can I implement this in the IronPython v2.6?
I write some code in c# as below,
ScriptEngine engine = Python.CreateEngine();
ScriptScope pyScope = engine.CreateScope();
ScriptSource ss;
ss = engine.CreateScriptSourceFromFile("D:\\test.py");
ss.Execute();
ScriptSource execute the whole python file now, how can I call the specific
function(for example, the GetScriptInfo() function)?
test.py file:
def GetScriptInfo ():
sXML='<script>script info</script>'
return sXML
def GetBodyInfo ():
sXML='<script>body info</script>'
return sXML
Thanks a lot!
Best Regards,
Evan Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100325/fafee4d4/attachment.html>
More information about the Ironpython-users
mailing list