[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Apr 26 03:23:19 CEST 2013
On 26/04/13 13:03, MRAB wrote:
> But there _is_ an ordering problem, in that the days wrap around.
Do we want a CircularEnum, then?
Ordering would be defined only up to the starting
value, which you would be required to specify when
doing anything where it mattered.
class Day(CircularEnum):
sunday = 0
monday = 1
...
saturday = 6
list(Day.startingat(Day.tuesday)) -->
[Day.tuesday, Day,wednesday, Day.thursday,
Day.friday, Day.saturday, Day.sunday,
Day.monday]
Modular arithmetic would apply, so
Day.saturday + 3 --> Day.tuesday
That would be the replacement for Day(3),
which would be disallowed.
--
Greg
More information about the Python-Dev
mailing list