Version: 9.12.0
enumerate.Enumerate Class Reference

This class emulates a C-like enum for python. More...

Public Member Functions

def __init__ (self, keys, offset=0)
 Canonical constructor. More...
 
def contains (self, key)
 Return true if this enumerate contains the specified key string. More...
 
def isValid (self, value)
 Returns true if the specified integer value is defined as an identifier in this enumerate. More...
 
def listkeys (self)
 Returns the list of keys in this enumerate. More...
 
def listvalues (self)
 Returns the list of values specified to initiate this enumerate. More...
 
def keyOf (self, value)
 Returns the symbolic key string associated to the specified identifier value. More...
 

Private Attributes

 _dict_keynumbers
 
 _dict_numberkeys
 

Detailed Description

This class emulates a C-like enum for python.

It is initialized with a list of strings to be used as the enum symbolic keys. The enum values are automatically generated as sequencing integer starting at the specified offset value.

Constructor & Destructor Documentation

◆ __init__()

def enumerate.Enumerate.__init__ (   self,
  keys,
  offset = 0 
)

Canonical constructor.

Parameters
keysa list of string to be used as the enum symbolic keys. The enum values are automatically generated as a sequence of integers starting at the specified offset value.

Member Function Documentation

◆ contains()

def enumerate.Enumerate.contains (   self,
  key 
)

Return true if this enumerate contains the specified key string.

Parameters
keya key string to test

References enumerate.Enumerate._dict_keynumbers, and KERNEL_PY.kernel.enumerate.Enumerate._dict_keynumbers.

◆ isValid()

def enumerate.Enumerate.isValid (   self,
  value 
)

Returns true if the specified integer value is defined as an identifier in this enumerate.

Parameters
valuea value to test

References enumerate.Enumerate._dict_numberkeys, and KERNEL_PY.kernel.enumerate.Enumerate._dict_numberkeys.

Referenced by enumerate.Enumerate.keyOf(), and KERNEL_PY.kernel.enumerate.Enumerate.keyOf().

◆ keyOf()

def enumerate.Enumerate.keyOf (   self,
  value 
)

Returns the symbolic key string associated to the specified identifier value.

Parameters
valuean integer value whose associated key string is requested.

References enumerate.Enumerate._dict_numberkeys, KERNEL_PY.kernel.enumerate.Enumerate._dict_numberkeys, enumerate.Enumerate.isValid(), and KERNEL_PY.kernel.enumerate.Enumerate.isValid().

◆ listkeys()

def enumerate.Enumerate.listkeys (   self)

Returns the list of keys in this enumerate.

References enumerate.Enumerate._dict_keynumbers, and KERNEL_PY.kernel.enumerate.Enumerate._dict_keynumbers.

◆ listvalues()

def enumerate.Enumerate.listvalues (   self)

Returns the list of values specified to initiate this enumerate.

References enumerate.Enumerate._dict_numberkeys, and KERNEL_PY.kernel.enumerate.Enumerate._dict_numberkeys.

Field Documentation

◆ _dict_keynumbers

◆ _dict_numberkeys