-
as seen on Stack Overflow
- Search for 'Stack Overflow'
When using Python CTypes there are the Structures, that allow you to clone c-structures on the Python side, and the POINTERS objects that create a sofisticated Python Object from a memory address value and can be used to pass objects by reference back and forth C code.
What I could not find on the…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I'm trying to determine the current working directory of a process given its PID. The command-line utility lsof does something similar. Here's the source to the python script:
import ctypes
from ctypes import util
import sys
PROC_PIDVNODEPATHINFO = 9
proc = ctypes.cdll.LoadLibrary(util.find_library("libproc"))
print(proc…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I have heard that Ctypes can cause crashes (or stop errors) in Python and windows. Should I stay away from their use? Where did I hear? It was back when I tried to control various aspects of windows, automation, that sort of thing.
I hear of swig, but I see Ctypes more often than not. Any danger…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
The C function myfunc operates on a larger chunk of data. The results are returned in chunks to a callback function:
int myfunc(const char *data, int (*callback)(char *result, void *userdata), void *userdata);
Using ctypes, it's no big deal to call myfunc from Python code, and to have the results…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I am dealing with image buffers, and I want to be able to access data a few lines into my image for analysis with a c library. I have created my 8-bit pixel buffer in Python using create_string_buffer. Is there a way to get a pointer to a location within that buffer without re-creating a new buffer…
>>> More