[Python-ideas] PEP for enum library type?

Antoine Pitrou solipsis at pitrou.net
Wed Feb 13 20:30:05 CET 2013


On Wed, 13 Feb 2013 13:19:14 -0500
Barry Warsaw <barry at python.org> wrote:
> On Feb 13, 2013, at 08:19 AM, Tim Delaney wrote:
> 
> >I'm of the opinion that the most fundamental property of an enum is that it
> >can generate its values automatically. Everything else is a nice-to-have,
> >but without that property it's not much use as an enum.
> 
> See, I don't care about that much because I define an enum once, but I *use*
> it hundreds of times.  Thus a little more verbosity/explicitness at definition
> time is a one-time cost, and a very low one at that.

The cost is not low when you have many values. Also, with many values
and one value per line, it can make your declaration very long
vertically.

And it's not always true that you use an enum much more often than you
define it. For example, you may define many error codes (e.g. errnos)
for compatibility with another system, but only check a few of them
explicitly in your application code.

Regards

Antoine.





More information about the Python-ideas mailing list