def enum(typename, field_names): "Create a new enumeration type" if isinstance(field_names, str): field_names = field_names.replace(',', ' ').split() d = dict((reversed(nv) for nv in enumerate(field_names)), __slots__ = ()) return type(typename, (object,), d)()