Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Commit de15e3a

Browse files
authored
Merge pull request #65 from PyMoDAQ/feature/str_enum
adding convenience class method to the StrEnum class
2 parents 75bee84 + a72c960 commit de15e3a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/pymodaq_utils/enums.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@
1010
from typing import List, Union
1111

1212

13+
class StrEnum(StrEnum): #to be imported in other modules
14+
@classmethod
15+
def names(cls) -> List[str]:
16+
"""Returns all the names of the enum"""
17+
return list(cls.__members__.keys())
18+
19+
@classmethod
20+
def values(cls) -> List[str]:
21+
"""Returns all the names of the enum"""
22+
return [cls[name].value for name in cls.names()]
23+
24+
25+
1326
class BaseEnum(Enum):
1427
"""Enum to be used within pymodaq with some utility methods"""
1528

0 commit comments

Comments
 (0)