Python's sad, unimaginative Enum

88888 Dihedral dihedral88888 at googlemail.com
Tue May 14 21:21:36 EDT 2013


Chris Angelico於 2013年5月14日星期二UTC+8上午1時36分34秒寫道:
> On Mon, May 13, 2013 at 8:17 PM, Steven D'Aprano
> 
> <steve+comp.lang.python at pearwood.info> wrote:
> 
> > Let's look at his major criticisms:
> 
> >
> 
> > 1) values aren't automatically generated.
> 
> >
> 
> > True. So what? That is the *least* important part of enums.
> 
> 
> 
> I stopped following the -ideas threads about enums, but IIRC
> 
> autogeneration of values was in quite a few of the specs early on. So
> 
> you can probably find the arguments against it in the list archives.
> 
> 
> 
> FWIW, though, I do like C's autogeneration of enum values - but use it
> 
> in only a small proportion of my enums. It's not a terrible loss, but
> 
> it is a loss.
> 
> 
> 
> ChrisA

Because a hash table can replace the enums in other languages,
it is more pythonic to use a dictionary built first
to replace the enums.

I think it is the same style of programming  in perl and ruby.



More information about the Python-list mailing list