-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Enum for constants #4
Comments
Just trying to maintain compatibility where convenient. For enum could use https://pypi.python.org/pypi/enum34/ for py2 (providing it doesn't cause problems) |
After some thinking I would advise to use the Here is a sample definition which suits your use case: from aenum import IntEnum
class Status(IntEnum):
_init_ = 'value', 'debug_message'
OK = 1, "debug message ok"
FAIL = 2, "debug message fail" The
I used In the end you should be able to use it like this with py2/py3: assert Status.OK == Status(1)
assert Status.OK.name == 'OK'
assert Status.OK.value == 1
assert Status.OK.debug_message == "debug message ok" |
Use
Enum
rather than variables or magic numbers for status and actionsI.e. go from this
To something like:
Definition
Usage
The text was updated successfully, but these errors were encountered: