pymel.util.enum.Enum

digraph inheritanceafc26bf885 {
rankdir=TB;
ranksep=0.15;
nodesep=0.15;
size="8.0, 12.0";
  "Enum" [fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,URL="#pymel.util.enum.Enum",style="setlinewidth(0.5)",height=0.25,shape=box,fontsize=8];
}

class Enum(name, keys, **kwargs)

Enumerated type

getIndex(key)

get an index value from a key. this method always returns an index. if a valid index is passed instead of a key, the index will be returned unchanged. this is useful when you need an index, but are not certain whether you are starting with a key or an index.

>>> units = Enum('units', ['invalid', 'inches', 'feet', 'yards', 'miles', 'millimeters', 'centimeters', 'kilometers', 'meters'])
>>> units.getIndex('inches')
1
>>> units.getIndex(3)
3
>>> units.getIndex('hectares')
Traceback (most recent call last):
  ...
ValueError: invalid enumerator key: 'hectares'
>>> units.getIndex(10)
Traceback (most recent call last):
  ...
ValueError: invalid enumerator index: 10
getKey(index)

get a key value from an index. this method always returns a key. if a valid key is passed instead of an index, the key will be returned unchanged. this is useful when you need a key, but are not certain whether you are starting with a key or an index.

>>> units = Enum('units', ['invalid', 'inches', 'feet', 'yards', 'miles', 'millimeters', 'centimeters', 'kilometers', 'meters'])
>>> units.getKey(2)
'feet'
>>> units.getKey('inches')
'inches'
>>> units.getKey(10)
Traceback (most recent call last):
  ...
ValueError: invalid enumerator index: 10
>>> units.getKey('hectares')
Traceback (most recent call last):
  ...
ValueError: invalid enumerator key: 'hectares'
keys()
return a list of keys as strings
values()
return a list of `EnumValue`s

Previous topic

pymel.util.enum.EnumValue

Next topic

pymel.util.enum.EnumValue

Core

Core Modules

Other Modules

This Page