.. Important:: Superseded by Python standard library.
Python 3 now has in its standard library an `enum`_
implementation (also available for older Python versions as
the third-party `enum34`_ distribution) that supersedes this
library.
.. _enum: https://docs.python.org/3/library/enum.html
.. _enum34: https://pypi.org/project/enum34/
This package provides a module for robust enumerations in Python.
An enumeration object is created with a sequence of string arguments
to the Enum() constructor::
>>> from enum import Enum
>>> Colours = Enum('red', 'blue', 'green')
>>> Weekdays = Enum('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun')
The return value is an immutable sequence object with a value for each
of the string arguments. Each value is also available as an attribute
named from the corresponding string argument::
>>> pizza_night = Weekdays[4]
>>> shirt_colour = Colours.green
The values are constants that can be compared only with values from
the same enumeration; comparison with other values will invoke
Python's fallback comparisons::
>>> pizza_night == Weekdays.fri
True
>>> shirt_colour > Colours.red
True
>>> shirt_colour == "green"
False
Each value from an enumeration exports its sequence index
as an integer, and can be coerced to a simple string matching the
original arguments used to create the enumeration::
>>> str(pizza_night)
'fri'
>>> shirt_colour.index
2
Raw data
{
"_id": null,
"home_page": "https://pypi.org/project/enum/",
"name": "enum",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "enum enumerated enumeration",
"author": "Ben Finney",
"author_email": "ben+python@benfinney.id.au",
"download_url": "https://files.pythonhosted.org/packages/02/a0/32e1d5a21b703f600183e205aafc6773577e16429af5ad3c3f9b956b07ca/enum-0.4.7.tar.gz",
"platform": "",
"description": ".. Important:: Superseded by Python standard library.\n\n Python 3 now has in its standard library an `enum`_\n implementation (also available for older Python versions as\n the third-party `enum34`_ distribution) that supersedes this\n library.\n\n .. _enum: https://docs.python.org/3/library/enum.html\n .. _enum34: https://pypi.org/project/enum34/\n\nThis package provides a module for robust enumerations in Python.\n\nAn enumeration object is created with a sequence of string arguments\nto the Enum() constructor::\n\n >>> from enum import Enum\n >>> Colours = Enum('red', 'blue', 'green')\n >>> Weekdays = Enum('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun')\n\nThe return value is an immutable sequence object with a value for each\nof the string arguments. Each value is also available as an attribute\nnamed from the corresponding string argument::\n\n >>> pizza_night = Weekdays[4]\n >>> shirt_colour = Colours.green\n\nThe values are constants that can be compared only with values from\nthe same enumeration; comparison with other values will invoke\nPython's fallback comparisons::\n\n >>> pizza_night == Weekdays.fri\n True\n >>> shirt_colour > Colours.red\n True\n >>> shirt_colour == \"green\"\n False\n\nEach value from an enumeration exports its sequence index\nas an integer, and can be coerced to a simple string matching the\noriginal arguments used to create the enumeration::\n\n >>> str(pizza_night)\n 'fri'\n >>> shirt_colour.index\n 2",
"bugtrack_url": null,
"license": "GPL-3.0+",
"summary": "Robust enumerated type support in Python.",
"version": "0.4.7",
"project_urls": {
"Homepage": "https://pypi.org/project/enum/"
},
"split_keywords": [
"enum",
"enumerated",
"enumeration"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "02a032e1d5a21b703f600183e205aafc6773577e16429af5ad3c3f9b956b07ca",
"md5": "e7d170e3f84435b77058de625c96ef58",
"sha256": "8c7cf3587eda51008bcc1eed99ea2c331ccd265c231dbaa95ec5258d3dc03100"
},
"downloads": -1,
"filename": "enum-0.4.7.tar.gz",
"has_sig": false,
"md5_digest": "e7d170e3f84435b77058de625c96ef58",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 20603,
"upload_time": "2018-08-22T05:13:36",
"upload_time_iso_8601": "2018-08-22T05:13:36.264537Z",
"url": "https://files.pythonhosted.org/packages/02/a0/32e1d5a21b703f600183e205aafc6773577e16429af5ad3c3f9b956b07ca/enum-0.4.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2018-08-22 05:13:36",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "enum"
}