How to use C enum in Python CTypes?
rozniy at gmail.com
Tue Aug 7 06:57:19 CEST 2007
I am using Python's CTypes module to import functions from a DLL into
Python. Some of the DLL's functions take enum type arguments, eg:
olDaGetDASS (HDEV hDev, OLSS OlSs, UINT uiElement, PHDASS phDass);
//(this function is in C form)
>From the header file, I found that type OLSS is an enum, like this:
typedef enum olss_tag
I managed to fudge the HDEV, UINT and PHDASS types as CTypes c_long(),
but I am not sure how translate a C enum into Python...
says that enumeration types is not implemented,
"Enumeration types are not implemented. You can do it easily yourself,
using c_int as the base class."
How do I do this? I am fairly new to Python, coming in from C++ (of
which I am utterly sick!)
More information about the Python-list