PEP 354: Enumerations in Python

Mikalai mbirukou at yahoo.com
Mon Feb 27 20:03:50 EST 2006


Steven D'Aprano wrote:
> Paul Rubin wrote:
>
> 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.

"Nothing" in python is None. If empty enum is None, then it is the same
as empty list in Lisp is nil, i.e. type-of(nil)=='list. Giving a type
to nothing, isn't really useful. Thus, empty enum is needed.

Programaticaly or, say, in implementation, enum is some structure that
holds some stuff. Just like tuples and lists are structures to hold
something. As a structure, it can be empty.




More information about the Python-list mailing list