Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Enum module supporting sequence, bitmask, and string enumerations

Project description

Yet Another Enumerator is an enum module that supports three different types of enumerations:

  • sequence enums (0, 1, 2, 3, etc.)
  • base 2 bitmask enums (0, 1, 2, 4, 8, etc.)
  • string enums (‘top’,’bottom’,’left’,’right’, etc.)

Each Enumeration is its own class, with instances of that class being singletons. Besides being a value, enum instances can also have their own behavior (use case, anyone?).

Creating an enum is as simple as:

from yaenum import Enum, BitMaskEnum, UniqueEnum, enum

Enum.create('Color', 'red green blue', export=globals())

or:

class Color(BitMaskEnum):       # python 3+ only
    black
    red
    green
    blue

and if that’s too magical for you:

class Color(BitMaskEnum):
    black = enum()              # python 2: enum(value=0) etc.
    red   = enum()
    green = enum()
    blue  = enum()

Project details


Release history Release notifications

This version

0.1

Download files

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

Files for yaenum, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size yaenum-0.1.tar.gz (8.3 kB) File type Source Python version None Upload date Hashes View hashes
Filename, size yaenum-0.1.zip (12.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page