Re: [Tutor] Python C extension - which method?

2018-05-07 Thread Michael C
Sorry I don't understand your suggestion. Use "ctypes.CDLL" and "ctypes.WinDLL" this works, mydll = cdll.LoadLibrary('test.dll') print(mydll.sum(3,2)) and this doens't mydll = cdll('test.dll') print(mydll.sum(3,2)) What's the syntax of what you suggested? Thanks On Mon, May 7, 2018 at 3:15

Re: [Tutor] Python C extension - which method?

2018-05-07 Thread eryk sun
On Mon, May 7, 2018 at 9:57 AM, Michael C wrote: > Sorry I don't understand your suggestion. > > Use "ctypes.CDLL" and "ctypes.WinDLL" > > this works, > mydll = cdll.LoadLibrary('test.dll') > print(mydll.sum(3,2)) > > and this doens't > mydll = cdll('test.dll') >

Re: [Tutor] Python C extension - which method?

2018-05-06 Thread eryk sun
On Sun, May 6, 2018 at 12:49 AM, Brad M wrote: > If I may ask, what's the difference between these two? > > 1) > import ctypes > hello = ctypes.WinDLL('hello', use_last_error=True) > > 2) > from ctypes import cdll > hello = cdll.LoadLibrary('hello.dll') Use ctypes.CDLL and

Re: [Tutor] Python C extension - which method?

2018-05-06 Thread Brad M
Does this have any downside? I have noticed that printf("HI") in my .DLL; doesn't really print anything. I am on windows. cdll.LoadLibrary('helloworld.dll') My next question is that I need to return an array or a list of address or int or some type of data, but if I returned a pointer to the

Re: [Tutor] Python C extension - which method?

2018-05-06 Thread Brad M
If I may ask, what's the difference between these two? 1) import ctypes hello = ctypes.WinDLL('hello', use_last_error=True) 2) from ctypes import cdll hello = cdll.LoadLibrary('hello.dll') Both of them can return "1980" from this: hello.c #include __declspec(dllexport) int

Re: [Tutor] Python C extension - which method?

2018-05-05 Thread Stefan Behnel
Hi, Brad M schrieb am 04.05.2018 um 11:30: > I want to create a C-based memory scanner for Python, and so far this is > how I do it: > > Python: > > from ctypes import cdll > mydll = cdll.LoadLibrary('hello.dll') > print(mydll.say_something()) > > and hello.dll: > > #include >

[Tutor] Python C extension - which method?

2018-05-05 Thread Brad M
Hi all: I want to create a C-based memory scanner for Python, and so far this is how I do it: Python: from ctypes import cdll mydll = cdll.LoadLibrary('hello.dll') print(mydll.say_something()) and hello.dll: #include __declspec(dllexport) int say_something() { return 1980; } so the