[Python-ideas] Enums

Eike Welk eike.welk at gmx.net
Thu Jul 28 15:10:39 CEST 2011


On Thursday 28.07.2011 00:24:09 Nick Coghlan wrote:
> 1. I find the "enum" concept too limiting. NamedValue (as a mixin
> class) is a better building block since it separates the naming aspect
> from the "group of values" aspect implied by enum. It would be nice,
> for example, if we could do things like "tau = NamedFloat('tau',
> 2*math.pi)" where NamedFloat is essentially just "class
> NamedFloat(NamedValue, float): pass" (this could, of course, be hidden
> behind a factory function that used type(value) and a cache to
> dynamically create appropriate subclasses)

+1 

Very nice idea!



More information about the Python-ideas mailing list