Cython doesn’t seem to allow me to reuse enum member names.
I have the following enums that I’m trying to cythonize:
from enum import Enum class Fruit(Enum): UNKNOWN = 0 APPLE = 1 ORANGE = 2 class Animal(Enum): UNKNOWN = 0 DOG = 1 CAT = 2
But the following results in a
'UNKNOWN' redeclared compilation error:
cpdef enum Fruit: UNKNOWN = 0 APPLE = 1 ORANGE = 2 cpdef enum Animal: UNKNOWN = 0 DOG = 1 CAT =
How should I fix the above?
Also, I’d ideally like to use
NULL as the enum member names instead of
UNKNOWN. But it seems that
NULL is a privileged keyword for Cython though it’s not for CPython. Is there any workaround?