[Python-ideas] constant/enum type in stdlib

João Bernardo jbvsmo at gmail.com
Mon Feb 4 00:53:26 CET 2013


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 couldn't find the best way to express enums with the current python
syntax, so I also wrote a simple
regex-parsed language to fit objects with an arbitrary level of complexity.
I think, enumeration per se
is not much more useful than just a bunch of integers... Having this kind
of control IMO is.

Although Java is not a good example of anything, they have a similar
feature. What do you people think?

João Bernardo


2013/2/3 Tim Delaney <timothy.c.delaney at gmail.com>

> On 4 February 2013 08:39, Tim Delaney <timothy.c.delaney at gmail.com> wrote:
>
>> Public repository on BitBucket: https://bitbucket.org/magao/enum
>>
>> Feel free to raise issues there, clone and make pull requests, etc.
>>
>
> As Eli has noted in the issues, no comments or anything except the unit
> tests yet. Lots of magic. Needs significant cleanup.
>
> And I'll note again in case it's not clear - this currently *only* works
> with Python 3.3.
>
> Tim Delaney
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130203/5e024275/attachment.html>


More information about the Python-ideas mailing list