[Python-ideas] constant/enum type in stdlib

Tim Delaney timothy.c.delaney at gmail.com
Mon Feb 4 01:17:29 CET 2013


On 4 February 2013 10:53, João Bernardo <jbvsmo at gmail.com> wrote:

> Hi, about this enum/const thing, The use case I like more is a class where
> you know all the
> instances and not just a sequence of names.
> Particularly It would be nice to have custom attributes and methods
> besides the value and the name.
>
> I have my own implementation with a basic api somewhat borrowed from
> flufl.enum (plus a lot of other stuff),
> but with this kind of support: https://github.com/jbvsmo/makeobj
>

I considered it, and in fact you could almost do it with my implementation
by using a custom subclass of EnumValue (except trying it has just exposed
a design flaw with the whole _EnumProxy bit). Works if you create the enum
in the same module as EnumValues, fails otherwise. Going to have to have a
rethink.

Tim Delaney
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130204/15f15a23/attachment.html>


More information about the Python-ideas mailing list