I use ctypes to access a shared library written in C. The C source of the shared library contains an enumeration of type
enum {
invalid = 0,
type1 = 1,
type2 = 2
} type_enum;
From the Python side, I intended to simply define integer constants for various enumeration values, for example:
INVALID = 0
TYPE1 = 1
TYPE2 = 2
And then use these numeric "constants" in the Python code calling the C functions. This seems to work fine, but I would strongly prefer to get the numerical values for the enums directly from the shared library (introspection?); however, using, for example, nm in a shared library, it does not seem to contain the characters "invalid", "type1" or "type2". So my question is:
- - " ", ?
- - Python/ctypes?