PEP 354: Enumerations in Python

Steven D'Aprano steve at REMOVEMEcyber.com.au
Mon Feb 27 02:34:23 EST 2006


Paul Rubin wrote:

> Ben Finney <bignose+python at benfinney.id.au> writes:
> 
>>Enumerations with no values are meaningless.  The exception
>>``EnumEmptyError`` is raised if the constructor is called with no
>>value arguments.
> 
> 
> Why are empty enumerations not allowed?  Empty sets, empty lists,
> empty dictionaries are all allowed.  I don't see any obvious benefits
> to not allowing empty enumerations.

What is an empty enum? How and when would you use it?

The best I can come up with is that an empty enum would 
be the enumerated values you have when you don't 
actually have any enumerated values. This is not to be 
confused with an empty list: an empty list is a 
well-defined concept. It is just a list (a container) 
with nothing in it. A list of X is like a box 
containing X, and like boxes, an empty list (or set, or 
dict) is meaningful. An enum of X is just the Xs 
themselves. If there is no X, there is nothing there.

But if you have a good usage case for an empty enum, 
please feel free to tell us.


-- 
Steven.




More information about the Python-list mailing list