Re: Enum questions.

2016-04-13 Thread Ethan Furman
On 04/13/2016 07:21 AM, Ethan Furman wrote: On 04/13/2016 07:07 AM, Marko Rauhamaa wrote: class Color(enum.Enum): red blue green This last one is to the point but raises a NameError. Using the aenum library that last one is possible. It also has NamedConstan

Re: Enum questions.

2016-04-13 Thread Ethan Furman
On 04/13/2016 07:07 AM, Marko Rauhamaa wrote: class Color(enum.Enum): red blue green This last one is to the point but raises a NameError. Using the aenum library that last one is possible. It also has NamedConstant and a metaclass-derived NamedTuple! --

Re: Enum questions.

2016-04-13 Thread Ian Kelly
On Wed, Apr 13, 2016 at 7:50 AM, Grant Edwards wrote: > FWIW, as an old Pascal programmer, I too would have been surprised > that an "enum" is not ordinal and doesn't support a next/prev and > iteration. They do support iteration, but it's by order of declaration, not by value. -- https://mail.p

Re: Enum questions.

2016-04-13 Thread Marko Rauhamaa
Grant Edwards : > On 2016-04-13, Michael Selik wrote: >> An Enum corresponds to "nominal" data that is coded as a number >> simply for storage rather than meaning. > > FWIW, as an old Pascal programmer, I too would have been surprised > that an "enum" is not ordinal and doesn't support a next/pre

Re: Enum questions.

2016-04-13 Thread Grant Edwards
On 2016-04-13, Michael Selik wrote: > On Wed, Apr 13, 2016, 12:14 PM Antoon Pardon > wrote: > >> I have been looking at the enum documentation and it seems enums >> are missing two features I rather find important. >> >> 1) Given an Enum value, someway to get the next/previous >>one >> >> 2)

Re: Enum questions.

2016-04-13 Thread Rustom Mody
On Wednesday, April 13, 2016 at 5:39:13 PM UTC+5:30, Michael Selik wrote: > On Wed, Apr 13, 2016, 12:14 PM Antoon Pardon > wrote: > > > I have been looking at the enum documentation and it > > seems enums are missing two features I rather find > > important. > > > > 1) Given an Enum value, someway

Re: Enum questions.

2016-04-13 Thread Michael Selik
On Wed, Apr 13, 2016, 12:14 PM Antoon Pardon wrote: > I have been looking at the enum documentation and it > seems enums are missing two features I rather find > important. > > 1) Given an Enum value, someway to get the next/previous >one > > 2) Given two Enum values, iterate over the values

Re: Enum questions.

2016-04-13 Thread jmp
On 04/13/2016 12:12 PM, Antoon Pardon wrote: I have been looking at the enum documentation and it seems enums are missing two features I rather find important. 1) Given an Enum value, someway to get the next/previous one 2) Given two Enum values, iterate over the values between them. D

Re: Enum questions.

2016-04-13 Thread Marko Rauhamaa
Rustom Mody : > Given the eg in the docs: > from enum import Enum > class Color(Enum): > red = 1 > blue = 2 > green = 3 > Color(Color.red.value+1) > But: >>> class Color(enum.Enum): ... red = 0xff ... green = 0x00ff00 ... blue = 0xff ... >>> Colo

Re: Enum questions.

2016-04-13 Thread Rustom Mody
On Wednesday, April 13, 2016 at 3:43:41 PM UTC+5:30, Antoon Pardon wrote: > I have been looking at the enum documentation and it > seems enums are missing two features I rather find > important. > > 1) Given an Enum value, someway to get the next/previous >one > > 2) Given two Enum values, it

Enum questions.

2016-04-13 Thread Antoon Pardon
I have been looking at the enum documentation and it seems enums are missing two features I rather find important. 1) Given an Enum value, someway to get the next/previous one 2) Given two Enum values, iterate over the values between them. Did I miss those in the documentation or are they