p_enum (version 0.4.4, 2009-08-26)
index
/home/goetz/project-shared/publish-HZB/projects/bii_scripts/bii_scripts/lib/python/bii_scripts/p_enum.py

Robust enumerated type support in Python.
 
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

 
Modules
       
sys

 
Classes
       
builtins.AssertionError(builtins.Exception)
EnumEmptyError(builtins.AssertionError, EnumException)
builtins.Exception(builtins.BaseException)
EnumException
EnumBadKeyError(builtins.TypeError, EnumException)
EnumEmptyError(builtins.AssertionError, EnumException)
EnumImmutableError(builtins.TypeError, EnumException)
builtins.TypeError(builtins.Exception)
EnumBadKeyError(builtins.TypeError, EnumException)
EnumImmutableError(builtins.TypeError, EnumException)
builtins.object
Enum
EnumValue

 
class Enum(builtins.object)
    Enum(*keys, **kwargs)
 
Enumerated type.
 
  Methods defined here:
__contains__(self, value)
__delattr__(self, name)
Implement delattr(self, name).
__delitem__(self, index)
__getitem__(self, index)
__init__(self, *keys, **kwargs)
Create an enumeration instance.
__iter__(self)
__len__(self)
__setattr__(self, name, value)
Implement setattr(self, name, value).
__setitem__(self, index, value)

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class EnumBadKeyError(builtins.TypeError, EnumException)
    EnumBadKeyError(key)
 
Raised when creating an Enum with non-string keys.
 
 
Method resolution order:
EnumBadKeyError
builtins.TypeError
EnumException
builtins.Exception
builtins.BaseException
builtins.object

Methods defined here:
__init__(self, key)
Initialize self.  See help(type(self)) for accurate signature.
__str__(self)
Return str(self).

Data descriptors defined here:
__weakref__
list of weak references to the object

Static methods inherited from builtins.TypeError:
__new__(*args, **kwargs) class method of builtins.TypeError
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from builtins.BaseException:
__reduce__(self, /)
Helper for pickle.
__repr__(self, /)
Return repr(self).
__setstate__(self, state, /)
add_note(self, note, /)
Add a note to the exception
with_traceback(self, tb, /)
Set self.__traceback__ to tb and return self.

Data descriptors inherited from builtins.BaseException:
__cause__
__context__
__dict__
__suppress_context__
__traceback__
args

 
class EnumEmptyError(builtins.AssertionError, EnumException)
    EnumEmptyError(*args, **kwargs)
 
Raised when attempting to create an empty enumeration.
 
 
Method resolution order:
EnumEmptyError
builtins.AssertionError
EnumException
builtins.Exception
builtins.BaseException
builtins.object

Methods defined here:
__str__(self)
Return str(self).

Data descriptors defined here:
__weakref__
list of weak references to the object

Static methods inherited from builtins.AssertionError:
__new__(*args, **kwargs) class method of builtins.AssertionError
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from EnumException:
__init__(self, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Methods inherited from builtins.BaseException:
__reduce__(self, /)
Helper for pickle.
__repr__(self, /)
Return repr(self).
__setstate__(self, state, /)
add_note(self, note, /)
Add a note to the exception
with_traceback(self, tb, /)
Set self.__traceback__ to tb and return self.

Data descriptors inherited from builtins.BaseException:
__cause__
__context__
__dict__
__suppress_context__
__traceback__
args

 
class EnumException(builtins.Exception)
    EnumException(*args, **kwargs)
 
Base class for all exceptions in this module.
 
 
Method resolution order:
EnumException
builtins.Exception
builtins.BaseException
builtins.object

Methods defined here:
__init__(self, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Data descriptors defined here:
__weakref__
list of weak references to the object

Static methods inherited from builtins.Exception:
__new__(*args, **kwargs) class method of builtins.Exception
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from builtins.BaseException:
__reduce__(self, /)
Helper for pickle.
__repr__(self, /)
Return repr(self).
__setstate__(self, state, /)
__str__(self, /)
Return str(self).
add_note(self, note, /)
Add a note to the exception
with_traceback(self, tb, /)
Set self.__traceback__ to tb and return self.

Data descriptors inherited from builtins.BaseException:
__cause__
__context__
__dict__
__suppress_context__
__traceback__
args

 
class EnumImmutableError(builtins.TypeError, EnumException)
    EnumImmutableError(*args)
 
Raised when attempting to modify an Enum.
 
 
Method resolution order:
EnumImmutableError
builtins.TypeError
EnumException
builtins.Exception
builtins.BaseException
builtins.object

Methods defined here:
__init__(self, *args)
Initialize self.  See help(type(self)) for accurate signature.
__str__(self)
Return str(self).

Data descriptors defined here:
__weakref__
list of weak references to the object

Static methods inherited from builtins.TypeError:
__new__(*args, **kwargs) class method of builtins.TypeError
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from builtins.BaseException:
__reduce__(self, /)
Helper for pickle.
__repr__(self, /)
Return repr(self).
__setstate__(self, state, /)
add_note(self, note, /)
Add a note to the exception
with_traceback(self, tb, /)
Set self.__traceback__ to tb and return self.

Data descriptors inherited from builtins.BaseException:
__cause__
__context__
__dict__
__suppress_context__
__traceback__
args

 
class EnumValue(builtins.object)
    EnumValue(enumtype, index, key)
 
A specific value of an enumerated type.
 
  Methods defined here:
__eq__(self, other) from _comparator.
Return self==value.
__ge__(self, other) from _comparator.
Return self>=value.
__gt__(self, other) from _comparator.
Return self>value.
__hash__(self)
Return hash(self).
__init__(self, enumtype, index, key)
Set up a new instance.
__le__(self, other) from _comparator.
Return self<=value.
__lt__(self, other) from _comparator.
Return self<value.
__ne__(self, other) from _comparator.
Return self!=value.
__repr__(self)
Return repr(self).
__str__(self)
Return str(self).

Readonly properties defined here:
enumtype
index
key

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
Data
        __author_email__ = 'ben+python@benfinney.id.au'
__author_name__ = 'Ben Finney'
__copyright__ = 'Copyright © 2007–2009 Ben Finney'
__license__ = 'Choice of GPL or Python license'
__url__ = 'http://pypi.python.org/pypi/enum/'

 
Author
        Ben Finney <ben+python@benfinney.id.au>