Exclude dictionaries for constant storage with enum34
Closed this issue · 0 comments
fsimkovic commented
The enum34
package is now distributed with CCP4. We should exchange previously converted objects back to enum34
data objects to be more consistent with how we store/access them and also comply with Python3.4 conventions.
A basic example would be the following:
class LogColors(object):
"""Color container for log messages"""
CRITICAL = 31
DEBUG = 34
DEFAULT = 0
ERROR = 31
WARNING = 33
This would be converted to
from enum34 import Enum
class LogColors(Enum):
"""Color container for log messages"""
critical = 31
debug = 34
default = 0
error = 31
warning = 33
Previously, we would access data using normal dict
conventions, now
>>> LogColors['critical'].name
CRITICAL
>>> LogColors['critical'].value
31
>>> LogColors(31)
<LogColors.critical: 31>
What are your thoughts on this @hlasimpk?