On 02/25/2013 07:46 PM, Stephen J. Turnbull wrote:
Ethan Furman writes:

  > Again:

Repeating yourself doesn't help make the case.  It does, however,
encourage me to reply.

Good!  For a while I felt like I was talking to myself!  ;)


  > Definition of ENUMERATE
  > 1 : to ascertain the number of : count
  > 2 : to specify one after another : list

You say you need the value as an integer; when you evaluate, you are
neither counting nor listing.

That's like saying when I evaluate a dict's key I'm neither assigning nor 
iterating.  True, but a fairly useless factoid.

When I /create/ the enumeration (by hand, until a couple days ago), I listed them and counted them all myself. Now I list them and let the computer count them. And both then and now when I use them the computer appropriately substitutes the already counted value for the name I listed. That counted value is every bit as important (at least in my use cases) as the set membership.

  Note that in both counting and listing
the object of the operation is not an element.  It is a set, and set
membership is the most important aspect of the elements for that
purpose.

No, it isn't. It may be in some cases. My enums even respect it to the point of not comparing equal to different enum sets. But, quite frankly, it's the enum's ability to let me use a name to mean a number that is the most important. And the most important thing for the Enum class is to assign those numbers for me as automatically as possible.


On the other hand, if you *are* going to access (constant!) values by
name, I don't see any reason to restrict the domain to integers.

I completely agree. I plan on making my enums support a wide range of possibilities. So far it's just int (counting and bitmap) and str.


 Nor do such named constants need to be members of any set in many cases.

For those cases I plan on using Nick's namedvalues.  But mostly I'll be using 
enumerations.

--
~Ethan~
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to