Skip to content

Commit

Permalink
StrEnum (#1663)
Browse files Browse the repository at this point in the history
  • Loading branch information
hainm authored Jun 27, 2024
1 parent 0147fee commit aea88de
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pytraj/all_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
try:
from enum import StrEnum
except ImportError:
from strenum import StrEnum
from enum import Enum
class StrEnum(str, Enum):
"""
Enum where members are also (and must be) strs.
"""
def __new__(cls, value):
member = str.__new__(cls, value) # Create a new instance of str with the given value
member._value_ = value # Set the _value_ attribute to the given value
return member


from typing import Any, Callable, List, Union
from functools import partial

Expand Down

0 comments on commit aea88de

Please sign in to comment.