[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
greg.ewing at canterbury.ac.nz
Fri Apr 26 05:14:51 CEST 2013
On 26/04/2013 1:28 p.m., Ethan Furman wrote:
> Interesting idea, but why does Day(3) have to be disallowed to make it
Because it's ambiguous. Which day of the week is number 3? It
depends on where you start.
I should perhaps point out that the numbers assigned to the
values initially are just to establish the relative ordering.
They wouldn't be directly accessible once the values are
created. To get an integer value corresponding to a Day value,
you would have to do arithmetic:
Day.wednesday - Day.sunday --> 3
More information about the Python-Dev