Dictionaries

A dictionary is like a list, except that you can index it by any sort of value.

>>> prim = { 'point' : 1, 'line' : 2, 'triangle' : 3 }
>>> prim['line']
2

A dictionary consists of keys and values. These can be retrieved via the functions keys and values.

      
>>> primitive.keys()
['line', 'triangle', 'point']
>>> primitive.values()
[2, 3, 1]