Package pike :: Module core :: Class Enum
[hide private]
[frames] | no frames]

Class Enum

source code

object --+    
         |    
      long --+
             |
            Enum
Known Subclasses:

Enumeration abstract base

An Enum subclasses long in order to ensure that instances are a member of a well-defined enumeration of values, provide introspection into the allowed values and their names, and provide symbolic string forms of values.

You should generally subclass one of ValueEnum or FlagEnum.

Nested Classes [hide private]
  __metaclass__
Instance Methods [hide private]
 
__repr__(self)
repr(x)
source code

Inherited from long: __abs__, __add__, __and__, __cmp__, __coerce__, __div__, __divmod__, __float__, __floordiv__, __format__, __getattribute__, __getnewargs__, __hash__, __hex__, __index__, __int__, __invert__, __long__, __lshift__, __mod__, __mul__, __neg__, __nonzero__, __oct__, __or__, __pos__, __pow__, __radd__, __rand__, __rdiv__, __rdivmod__, __rfloordiv__, __rlshift__, __rmod__, __rmul__, __ror__, __rpow__, __rrshift__, __rshift__, __rsub__, __rtruediv__, __rxor__, __sizeof__, __str__, __sub__, __truediv__, __trunc__, __xor__, bit_length, conjugate

Inherited from object: __delattr__, __init__, __reduce__, __reduce_ex__, __setattr__, __subclasshook__

Class Methods [hide private]
 
items(cls)
Returns a list of (name,value) pairs for allowed enumeration values.
source code
 
names(cls)
Returns a list of names of allowed enumeration values.
source code
 
values(cls)
Returns a list of allowed enumeration values.
source code
 
import_items(cls, dictionary)
Import enumeration values into dictionary
source code
 
validate(cls, value)
Validate value as valid for enumeration.
source code
Static Methods [hide private]
a new object with type S, a subtype of T
__new__(cls, value=0)
Constructor.
source code
Class Variables [hide private]
  _nametoval = {}
  _valtoname = {}
Properties [hide private]

Inherited from long: denominator, imag, numerator, real

Inherited from object: __class__

Method Details [hide private]

import_items(cls, dictionary)
Class Method

source code 

Import enumeration values into dictionary

This method is intended to allow importing enumeration values from an Enum subclass into the root of a module, and should be invoked as:

   SomeEnumClass.import_items(globals())

validate(cls, value)
Class Method

source code 

Validate value as valid for enumeration.

This must be implemented in subclasses of Enum (but not ValueEnum or FlagEnum, which provide it). It should raise a ValueError on failure.

__new__(cls, value=0)
Static Method

source code 

Constructor.

Creates a new Enum instance from an ordinary number, validating that is is valid for the particular enumeration.

Returns: a new object with type S, a subtype of T
Overrides: object.__new__

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)