[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
ethan at stoneleaf.us
Fri Apr 26 03:28:17 CEST 2013
On 04/25/2013 06:23 PM, Greg Ewing wrote:
> 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,
> Modular arithmetic would apply, so
> Day.saturday + 3 --> Day.tuesday
> That would be the replacement for Day(3),
> which would be disallowed.
Interesting idea, but why does Day(3) have to be disallowed to make it work?
More information about the Python-Dev