[Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as

Antoine Pitrou solipsis at pitrou.net
Mon Feb 25 17:43:08 CET 2013


Le Mon, 25 Feb 2013 11:37:29 -0500,
Barry Warsaw <barry at python.org> a écrit :
> On Feb 25, 2013, at 07:12 AM, Ethan Furman wrote:
> 
> >And if, in those places, the enums were based on ints (or strings),
> >would it hurt you?  Because in the places where I, as well as many
> >others, use enums we *need* the int portion; and having to wrap the
> >enum in an int() call is seven extra keystrokes (minor) and a heap
> >of visual clutter (major), destroying any value the enum was
> >supposed to have.
> 
> Yes, I think enum values inheriting from int (or string) would hurt.
> 
> First, as your question implies, which is it?  int or str?  Some
> people want int some want str.  It can't be both, and I don't think
> we need two enum types.

I think we do "need" two enum types (as far as some enum mechanism is
needed).
str is better for most pure-Python uses, but int is necessary for a lot
of portability / compatibility requirements.

Regards

Antoine.




More information about the Python-Dev mailing list