I have a string variable named status in my code that can take on three values "Starting", "In-progress", and "Complete". A friend of mine said it was good practice to enforce that status has one of those three values by using an enum. What is the best practice way to do this? (And for what it's worth, is an enum the right tool to use here?)
I've tried :
class Status(Enum):
Starting = "Starting"
InProgress = "In-progress"
Complete = "Complete"
and then in my code I have assert statements as so:
assert(status in Status._value2member_map_)
Is this the right way to do it, or is there something else better?
status in Status
?Status(status)
then, it throws a ValueError if invalid.