PEP 354: Enumerations in Python

greg greg at cosc.canterbury.ac.nz
Wed Mar 1 04:28:36 EST 2006


Dan Sommers wrote:

> In some parts of the world, calendar weeks begin on Monday
> and end on Sunday, and in other parts of the world, work weeks begin on
> Sunday and end on Thursday.

Things like days of the week really have a circular
ordering, so it doesn't inherently make sense to
ask whether one day of the week is less than or
greater than another.

Maybe there should be a circular_enum type, where
order comparisons even among the *same* type are
disallowed?

Another thought -- should enum values have pred()
and succ() methods, like in Pascal? If so, for
a circular_enum these should wrap around.

--
Greg



More information about the Python-list mailing list