The following code works on arbitrary lists:
import ctypes
py_values = [1, 2, 3, 4]
arr = (ctypes.c_int * len(py_values))(*py_values)
More Related Contents:
- C function called from Python via ctypes returns incorrect value
- Python Ctypes – loading dll throws OSError: [WinError 193] %1 is not a valid Win32 application
- Wrapping a C library in Python: C, Cython or ctypes?
- python ctypes issue on different OSes
- What files are required for Py_Initialize to run?
- How to pass a 2d array from Python to C?
- ctypes error: libdc1394 error: Failed to initialize libdc1394
- Approximating data with a multi segment cubic bezier curve and a distance as well as a curvature contraint
- Python (and Python C API): __new__ versus __init__
- How do you call Python code from C code?
- Py_initialize / Py_Finalize not working twice with numpy
- Extending setuptools extension to use CMake in setup.py?
- Getting data from ctypes array into numpy
- Changing LD_LIBRARY_PATH at runtime for ctypes
- How can I unload a DLL using ctypes in Python?
- ctypes – Beginner
- What does “Symbol not found / Expected in: flat namespace” actually mean?
- Run a python script with arguments
- How to use IFileOperation from ctypes
- python ctype recursive structures
- How do I set the desktop background in python? (windows)
- Can’t import dll module in Python
- Maximum and minimum value of C types integers from Python
- Can I access ImageMagick API with Python?
- Convert word2vec bin file to text
- Calling Python script from C++ and using its output
- Building Mesa for windows 7. Mesa 9.1
- Multithreading with Python and C api
- Passing numpy arrays in Cython to a C function that requires dynamically allocated arrays
- Embedding python in multithreaded C application