Dec. 13, 2021
11:34 p.m.
On Mon, Dec 13, 2021 at 06:43:27AM -0000, Vioshim wrote:
Anyways, at the moment that I write this message in python3.10.1, It happens that when making a class with the dataclasses module, this class can't actually be used in Multiple inheritance for Enum purposes, this is mostly to avoid code repetition by having to write the methods over again. [...] class Entries(Foo, Enum): ENTRY1 = Foo(1) ENTRY2 = Foo(2) ENTRY3 = Foo(3)
I think this may be what you are looking for:
class Entries(Foo, Enum): ... ENTRY1 = 1 ... ENTRY2 = 2 ... Entries.ENTRY1 Entries(a=1) Entries.ENTRY1.a 1 isinstance(Entries.ENTRY2, Foo) True
-- Steve