I have a simple listing in C in myenum.h:
enum MyEnum { ONE, TWO, THREE };
The problem is that when I map this to Python, I can only access the enumeration through the module name, not through MyEnum. So the ONE, TWO, THREE values ββare included in any other functions that I define, instead of containing MyEnum.
My api.i file:
%module api %{ #include "myenum.h" %} %include "myenum.h"
I generate using SWIG
swig -builtin -python api.i
And import it in Python
import _api
And now I have to use the enum values ββfrom the _api module:
_api.ONE _api.TWO _api.THREE
While I want to use them as
_api.MyEnum.ONE _api.MyEnum.TWO _api.MyEnum.THREE
Does anyone know how I can do this?
c python swig
mindvirus
source share