<jupyter_start><jupyter_text>Python in Action Part 1: Python Fundamentals 08 &mdash; Enums in Python> enumerated valuesEnums are readable names bound to constant values:<jupyter_code>from enum import Enum

class State(Enum):
    DISABLED = 0
    ENABLED = 1

print(State.ENABLED) # will print 'State.ENABLED' and not 1<jupyter_output>State.ENABLED<jupyter_text>There are some other ways to refer to enums:<jupyter_code>print(State(1))
print(State['DISABLED'])<jupyter_output>State.ENABLED
State.DISABLED<jupyter_text>And you can get the underlying value using its `value` property:<jupyter_code>print(State.DISABLED.value)<jupyter_output>0<jupyter_text>You can also list and count the different values of an enum:<jupyter_code>print(list(State))
print(len(State))<jupyter_output>[<State.DISABLED: 0>, <State.ENABLED: 1>]
2
{'fraction_non_alphanumeric': 0.10218978102189781, 'fraction_numerical': 0.01338199513381995, 'mean_word_length': 7.663157894736842, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '649021', 'license': 'MIT', 'n_tokens_mistral': 295, 'n_tokens_neox': 295, 'n_words': 73, 'path': '01-python-basics/08-python-enums.ipynb', 'repo_name': 'sergiofgonzalez/python-in-action', 'size': '822'}