-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Labels
Description
in java, FlatBuffers will generate name() method for enums, which is very helpful.
public static final String[] names = { "SUCCESS", "TIME_OUT", "UNKNOWN_ERROR", };
public static String name(int e) { return names[e]; }
so does it in c++
inline const char **EnumNamesResultCode() {
static const char *names[] = { "SUCCESS", "TIME_OUT", "UNKNOWN_ERROR", nullptr };
return names;
}
inline const char *EnumNameResultCode(ResultCode e) { return EnumNamesResultCode()[static_cast<int>(e)]; }
but in python, there is no such method. it just generate a pure class with some constants.
class ResultCode(object):
SUCCESS = 0
TIME_OUT = 1
UNKNOWN_ERROR = 2
how to generate name() method in python?
in other words, how can I get enum names in python?
Reactions are currently unavailable