by bilboa · 5y ago · 0 comments
Edit: It is possible to use constants or variables in a case pattern, but they have to be dotted names to not be treated like a capture pattern. So this would work for your example:
class HttpStatus(Enum):
NOT_FOUND = 404
match status:
case HttpStatus.NOT_FOUND:
return "Not found" def _id(x): return x
not_found = 404
match status:
case _id(not_found):
return "Not found"