PEP 354: Enumerations in Python
Steven Bethard
steven.bethard at gmail.com
Wed Mar 1 02:56:21 EST 2006
Ben Finney wrote:
> Steven Bethard <steven.bethard at gmail.com> writes:
>
>> Ben Finney wrote:
>>> This PEP specifies an enumeration data type for Python.
>>> An enumeration is an exclusive set of symbolic names bound to
>>> arbitrary unique values. Values within an enumeration can be iterated
>>> and compared, but the values have no inherent relationship to values
>>> outside the enumeration.
>> -1 on the proposal as-is. I don't have many use cases for
>> enumerations, and I don't think they merit appearing in the builtins.
>> If you put them in the collections module instead, I'd probably be +0.
>
> This seems to be a common distinction.
>
> Should I amend the PEP to propose "either in the builtins or in the
> collections module"? Or should I propose two PEPs and let them
> compete?
I would probably just amend the PEP. I have a feeling that python-dev
is even less likely to accept it as a builtin than python-list is.
>> For the few cases of enumerations that I've needed, I've never
>> wanted them to be comparable with <, >, etc. If there were two
>> classes, say ``collections.Enum`` and ``collections.OrderedEnum``
>> where only the latter made the enumerated items comparable, you
>> might even get me as high as +0.5. (I only care about the
>> non-comparable one, but I understand that others may have a need for
>> the comparable one.)
>
> Replies to your post indicate this is another popular distinction.
>
> But the terminology is broken. The term "enumerated" seems to me to
> imply that it does have an order.
I didn't get that implication. From WordNet 2.0:
"""
enumerate
v 1: specify individually; "She enumerated the many obstacles she had
encountered"; "The doctor recited the list of possible side effects of
the drug" [syn: recite, itemize, itemise] 2: determine the number or
amount of; "Can you count the books on your shelf?"; "Count your change"
[syn: count, number, numerate]
"""
I don't get an ordering out of either of the definitions above. But
certainly there are a few precedents (e.g. Java's Enumeration interface)...
> Can you suggest a term other than
> "enumerated" for what you're describing with the unordered property?
I don't have any good names if people think that enumeration implies
ordering. Off of thesaurus.reference.com:
* numbering
* inventory
* lexicon
* catalogue
Those were the best I saw, and they're pretty bad. I guess you could go
with ``symbols`` maybe...
STeVe
More information about the Python-list
mailing list