Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013年4月25日 18:53:29 -0700

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,
 Day.monday]
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?
--
~Ethan~
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to