Closed hsorby closed 1 year ago
The reason for starting from 1
is that it's what is done by default in Python (see https://docs.python.org/3/library/enum.html#enum.auto), e.g.
from enum import Enum, auto
class Color(Enum):
RED = auto()
GREEN = auto()
BLUE = auto()
is the same as:
from enum import Enum
class Color(Enum):
RED = 1
GREEN = 2
BLUE = 3
So, if we want to generate Python code that looks Pythonic (rather than like C) then I would stick to what we have. So, if anything, I would use auto()
-based version.
While I am very much in favour of making the generated code look Pythonic, I also want to get consistency across the code generation. Currently, when I compare the enumerated values for variables from the generated code from different profiles I get back different values. This to me is a problem that overrides the desire to be Pythonic.
Why would an end user want / need to do such a comparison?
For code generation of the Python profile enumerations of the VariableType are initialised to start at
1
. However, the C++ equivalent is initialised at0
. I think this should be made consistent across the code generation profiles.This means initialising our Python generated enumeration code to start from
0
and not1
.