Skip to main content

Robust enumerated type support in Python

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

enum-0.4.2.tar.gz (20.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

enum-0.4.2-py2.5.egg (6.4 kB view details)

Uploaded Egg

enum-0.4.2-py2.4.egg (6.5 kB view details)

Uploaded Egg

enum-0.4.2-py2.3.egg (18.4 kB view details)

Uploaded Egg

File details

Details for the file enum-0.4.2.tar.gz.

File metadata

  • Download URL: enum-0.4.2.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for enum-0.4.2.tar.gz
Algorithm Hash digest
SHA256 2e0ee95a88774b9a74f92875149c6e57573fe9da412b27750df3ca81987f4f12
MD5 de84f1b3f85e5f926bb9700fee2ed4f8
BLAKE2b-256 fd4cbcd8d97668916d1514c6b9c7a4abda12254da43e278838b635feeefed6bb

See more details on using hashes here.

File details

Details for the file enum-0.4.2-py2.5.egg.

File metadata

  • Download URL: enum-0.4.2-py2.5.egg
  • Upload date:
  • Size: 6.4 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for enum-0.4.2-py2.5.egg
Algorithm Hash digest
SHA256 c7e8ac234528c9f38772607283c92f25672bdddf3b51a924bd7d862b0bc89aeb
MD5 ececa663519f958b348a6c271cd76c5a
BLAKE2b-256 2c4165aaf532dfbd95e8b5f4b80e19114f97d5c9e69ba51ba5fdae3e1be23c90

See more details on using hashes here.

File details

Details for the file enum-0.4.2-py2.4.egg.

File metadata

  • Download URL: enum-0.4.2-py2.4.egg
  • Upload date:
  • Size: 6.5 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for enum-0.4.2-py2.4.egg
Algorithm Hash digest
SHA256 344d7d588c7eaab8a22375a7f53ed3d4cae1ac13b31ff5957536034bea068a36
MD5 81b4acd4999c7b691344b9a33d593205
BLAKE2b-256 53e18c74eb059b8293effb7518c5079fbf22e824fe4d82710bd6be34fdf32dfa

See more details on using hashes here.

File details

Details for the file enum-0.4.2-py2.3.egg.

File metadata

  • Download URL: enum-0.4.2-py2.3.egg
  • Upload date:
  • Size: 18.4 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for enum-0.4.2-py2.3.egg
Algorithm Hash digest
SHA256 e6e5a531ae7decdcad2b88d90304defec1fc3b8e4a11776dbb701fc8f5dab3a7
MD5 d6d8011cfc60d5afd5454e14bac739a9
BLAKE2b-256 32bfae80321a81078b491460ffec36f3a613eb4ff66e71d2c8e59699ae123c70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page