Reputation: 31
I'm a newbie to Python and C#. I'm trying to make a dll in C# with two methods implemented as interface, and call them in python file after registering in COM.
namespace Sample
{
public interface interf
{
bool printHello(string name);
void printWorld();
}
public class A : interf
{
public bool printHello(string name)
{
Console.WriteLine(name);
return true;
}
public void printWorld()
{
Console.WriteLine("World!");
}
}
}
I'm calling these functions in python as:
import win32com.client
dllCall = win32com.client.Dispatch("Sample.A")
hello = dllCall.printHello("Hello")
dllCall.printWorld()
I'm getting the following error when I try to execute the python file.
Hello
Traceback (most recent call last):
File "C:\Temp\sampleTest.py", line 23, in <module>
World!
dllCall.printWorld()
TypeError: 'NoneType' object is not callable
What is that I'm missing?
Upvotes: 2
Views: 766
Reputation: 31
Finally I got it working.
If I call printWorld
without brackets ()
.
dllCall.printWorld
Upvotes: 1