Skip to main content

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())


class Color(BitMaskEnum):       # python 3+ only

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 | RSS feed

This version


Download files

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

Source Distributions (12.6 kB view hashes)

Uploaded source

yaenum-0.1.tar.gz (8.3 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page