Python/enum: Revision history

Jump to navigation Jump to search

Diff selection: Mark the radio buttons of the revisions to compare and hit enter or the button at the bottom.
Legend: (cur) = difference with latest revision, (prev) = difference with preceding revision, m = minor edit.

17 September 2025

16 September 2025

  • curprev 19:5819:58, 16 September 2025Kenneth talk contribs 1,852 bytes +1,852 Created page with "== enum — Support for enumerations == Python 3: enum — Support for enumerations https://docs.python.org/3/library/enum.html <pre> from enum import Enum # class syntax class Color(Enum): RED = 1 GREEN = 2 BLUE = 3 # functional syntax Color = Enum('Color', ['RED', 'GREEN', 'BLUE']) </pre> Convert string name or value to enum: <pre> def value_to_enum(color_value_str): try: return Color(color_value_str) except ValueError: retu..."