[Python-ideas] constant/enum type in stdlib

Joao S. O. Bueno jsbueno at python.org.br
Fri Feb 1 21:19:49 CET 2013


On 1 February 2013 18:09, Eric Snow <ericsnowcurrently at gmail.com> wrote:

> On Fri, Feb 1, 2013 at 12:30 PM, Eli Bendersky <eliben at gmail.com> wrote:
> > On Fri, Feb 1, 2013 at 7:36 AM, Barry Warsaw <barry at python.org> wrote:
> >> Why not package it up and put it in PyPI?  Better there than sitting in
> an
> >> email thread of some mailing list full of crazy people. :)
> >
> > I would actually prefer a place where it's easy to see the code, comment
> on
> > it and fork it like Bitbucket or Github. PyPI is good for other
> purposes...
>
> +1
>
> And put it on PyPI to make it more accessible.
>

As soon as there are some more goodies in there beyond the enumerator and
constants themselves.

I can see that a namedtuple - like utility function could be interesting to
create the enums -
and a way to import the generated constatnts to the current global
namespace that does not
violate good pratices.


I think that something like:

class MyEnum(Enum):
     RED, GREEN, BLUE

load_constants(MyEnum, globals() )

is a good solution that could respect both DRY and "explicit is better than
implicit"
and "Special cases aren't special enough to break the rules."

   js
  -><-

>
> -eric
> _______________________________________________
> 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/20130201/785aed13/attachment.html>


More information about the Python-ideas mailing list