Original Post
I have problem with calling a python function(in .py file) using C# I used [Added the [source] tag to preserve formatting and add syntax highlighting - Oluseyi] In the Above program i am loading only the module name as pyPortalFun But i have a problem with calling fun() function in PyPortalFun.py from C# Thanks.. K.V.N.Kumar Apollo Health Street Limited narasimhakumar_k@apollolife.com Hyderabad [Edited by - Oluseyi on October 13, 2005 12:40:53 PM]
PyPortalFun.py
def fun():
print "hai"
I included the Python.Runtime dll I have written C# code as
using System;
using Python.Runtime;
namespace MainProgram
{
class PyTestClass
{
public PyTestClass()
{
PythonEngine.Initialize();
}
[STAThread]
static void Main(string[] args)
{
PyTestClass pyTest = new PyTestClass();
try
{
if(!PythonEngine.IsInitialized)
throw new Exception("PythonEngine not initialized.");
PyObject module= PythonEngine.ImportModule("PyPortalFun");
}
catch(Exception e)
{
Console.WriteLine(e.Message);
Console.Write(e.StackTrace);
}
}
}
}