From a72c960c0e49ed0338aed6a6066f84e75731fda1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Weber?= Date: Wed, 24 Sep 2025 20:57:54 +0200 Subject: [PATCH] adding convenience class method to the StrEnum class --- src/pymodaq_utils/enums.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pymodaq_utils/enums.py b/src/pymodaq_utils/enums.py index d8da7993..2f3f1294 100644 --- a/src/pymodaq_utils/enums.py +++ b/src/pymodaq_utils/enums.py @@ -10,6 +10,19 @@ from typing import List, Union +class StrEnum(StrEnum): #to be imported in other modules + @classmethod + def names(cls) -> List[str]: + """Returns all the names of the enum""" + return list(cls.__members__.keys()) + + @classmethod + def values(cls) -> List[str]: + """Returns all the names of the enum""" + return [cls[name].value for name in cls.names()] + + + class BaseEnum(Enum): """Enum to be used within pymodaq with some utility methods"""