Skip to content

Instantly share code, notes, and snippets.

@oyvinev
Created January 3, 2019 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oyvinev/362a2f8be13e536323f700597ed42a4d to your computer and use it in GitHub Desktop.
Save oyvinev/362a2f8be13e536323f700597ed42a4d to your computer and use it in GitHub Desktop.
import enum
import operator
OperatorEnum = enum.Enum(
"operator",
{"==": operator.eq, ">=": operator.ge, "<=": operator.le, ">": operator.gt, "<": operator.lt},
)
print(OperatorEnum["=="].value)
OperatorEnum["foo"] # pass
OperatorEnum.foo # Fails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment