Can named arguments be used with Python enums?
问题 Example: class Planet(Enum): MERCURY = (mass: 3.303e+23, radius: 2.4397e6) def __init__(self, mass, radius): self.mass = mass # in kilograms self.radius = radius # in meters Ref: https://docs.python.org/3/library/enum.html#planet Why do I want to do this? If there are a few primitive types (int, bool) in the constructor list, it would be nice to used named arguments. 回答1: While you can't use named arguments the way you describe with enums, you can get a similar effect with a namedtuple mixin: