Enum types (in other languages as well as Python) generally aren't meant to be made such that the type itself has data. I'm also confused, because traditionally, you don't want the enum type's name to be obscured. An enum is for classification amongst a discrete set of types/attributes. Traditionally, you would have a solution like the following:
from enum import Enum class TransportKind(Enum): Car = 1 Train = 2 class Transport(object): def __init__(self, transport_kind: TransportKind, other_value: int, **extra_data): self.transport_kind = transport_kind self.other_value = other_value for k, v in extra_data.items(): setattr(self, k, v) ... ts = Transport(transport_kind=TransportKind.Car, other_value=2, id=5)
And somewhere, whereever relevant, you'd dispatch depending on ts.transport_kind to have different behavior and different expected attributes.
That said, an even more traditional-such approach is simply object-oriented programming:
class Transport(object): def __init__(self, id: int, other_value: int): self.id = id self.other_value = other_value class Car(Transport): pass class Train(Transport): pass ... ts = Car(other_value=2, id=5)
Then later on use dispatching (dynamic, double using the visitor pattern, or even just a simple instanceof check) based on the class itself.
If you are so dead-set on doing things the way you propose, it would involve subclassing Enum or even subclassing the internal EnumMeta and altering its behavior, which gets very messy very quickly.
E: Fixed an assumption I made in the second example
car : Cardoes nothing, it doesn't create a class attribute. Creating class attributes is done withcar = ...- but I'm not really sure of what you are really trying to achieve here...