I am currently struggling with writing IronPython modules in C #. First, I have some empty partial class that represents the base of the module:
[assembly: PythonModule("demo", typeof(Demo.IronPythonAPI.PythonAPIModule))]
namespace Demo.IronPythonAPI
{
public static partial class PythonAPIModule
{
}
}
In some other files, I'm trying to implement modules:
namespace Demo.IronPythonAPI
{
public static partial class PythonAPIModule
{
[PythonType]
public static class Sql
{
public static int executeNoneQuery(string query, string conName)
{
Console.WriteLine("Hello World");
return 0;
}
}
}
}
If now I want to use the module, it does not work:
import demo
Sql.executeNoneQuery("", "")
This throws an exception:
name 'Sql' not defined
Using
from demo import Sql
Sql.executeNoneQuery("", "")
Everything works perfectly. What did I really do wrong?
Many thanks!
source
share