{"id":1473,"library":"enum34","title":"Python 3.4 Enum Backport (enum34)","description":"`enum34` backports the `enum.Enum` class from Python 3.4 to older Python versions (2.4-3.3), enabling the use of enumerated types across diverse legacy environments. It also includes selected features from newer Python `enum` modules, such as `auto()` and `Flag` from Python 3.6. The library is currently at version 1.1.10, and due to its nature as a backport, active development has ceased, though it remains functional and stable for its intended purpose.","status":"maintenance","version":"1.1.10","language":"en","source_language":"en","source_url":"https://bitbucket.org/stoneleaf/enum34","tags":["enum","backport","python2","python3","legacy","compatibility"],"install":[{"cmd":"pip install enum34","lang":"bash","label":"Install `enum34`"}],"dependencies":[],"imports":[{"note":"For Python versions prior to 3.4, `Enum` must be imported from `enum34`.","wrong":"from enum import Enum","symbol":"Enum","correct":"from enum34 import Enum"},{"note":"For Python versions prior to 3.4, `IntEnum` must be imported from `enum34`.","wrong":"from enum import IntEnum","symbol":"IntEnum","correct":"from enum34 import IntEnum"},{"note":"The `auto()` function was introduced in standard `enum` in Python 3.6. For older Pythons using `enum34`, it must be imported from `enum34`.","wrong":"from enum import auto","symbol":"auto","correct":"from enum34 import auto"}],"quickstart":{"code":"from enum34 import Enum, auto\n\nclass Color(Enum):\n    RED = auto()\n    GREEN = auto()\n    BLUE = auto()\n\n    def __str__(self):\n        return self.name.lower()\n\nprint(f\"First color: {Color.RED}\")\nprint(f\"Value of GREEN: {Color.GREEN.value}\")\nprint(f\"Access by value (1): {Color(1)}\")\nprint(f\"Iterating through colors:\")\nfor color in Color:\n    print(f\"- {color.name}: {color.value}\")","lang":"python","description":"Defines a basic `Enum` using `auto()` for automatic value assignment and demonstrates accessing members by name, value, and iteration."},"warnings":[{"fix":"Remove `enum34` from your dependencies and switch to `from enum import Enum` (or `IntEnum`, `auto`, etc.) for Python 3.4 and later.","message":"`enum34` should NOT be used on Python 3.4 or newer. Python 3.4 introduced the `enum` module into the standard library. Using `enum34` on these versions can lead to conflicts, unexpected behavior, or unnecessary overhead. Always use the built-in `enum` module for Python 3.4+.","severity":"breaking","affected_versions":"Python >= 3.4"},{"fix":"Thoroughly test your enum implementations, especially when using advanced features like `auto()` or `Flag`, if targeting a wide range of Python versions or migrating to/from native `enum`.","message":"While `enum34` primarily backports `Enum` from Python 3.4, it also includes features like `auto()`, `Flag`, and `StrEnum` which were introduced in later Python versions (3.6 and 3.11 respectively). Be aware that the behavior of these backported features might have subtle differences or limitations compared to their native implementations in newer Python versions.","severity":"gotcha","affected_versions":"All versions when comparing to native `enum` in Python >= 3.6/3.11"},{"fix":"If starting a new project or upgrading an existing one to Python 3.4+, do not install `enum34`. Rely solely on the standard library's `enum` module.","message":"For all new Python projects or projects targeting Python 3.4 or newer, `enum34` is obsolete. Its sole purpose is to provide `enum` functionality to legacy Python 2 and early Python 3 environments (up to 3.3).","severity":"deprecated","affected_versions":"All versions (in context of new projects)"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}