8.26.1 ODict class: An ordered dictionary.

This is a dictionary that keeps the keys in order. The default order is the insertion order. The current order can be changed at any time.

The ODict class has this constructor:

class ODict( data=)
Create a new ODict instance.

The ODict can be initialized with a Python dict or an ODict. The order after insertion is indeterminate if a plain dict is used.

ODict objects have the following methods:

__repr__( )
Format the Dict as a string.

We use the format Dict(), so that the string is a valid Python representation of the Dict.

__setitem__( key,value)
Allows items to be set using self[key] = value.

__delitem__( key)
Allow items to be deleted using del self[key].

Raises an error if key does not exist.

update( data=)
Add a dictionary to the ODict object.

The new keys will be appended to the existing, but the order of the added keys is undetemined if data is a dict object. If data is an ODict its order will be respected..

__add__( data)
Add two ODicts's together, returning the result.

sort( keys)
Set the order of the keys.

keys should be a list containing exactly all the keys from self.

keys( )
Return the keys in order.

values( )
Return the values in order of the keys.

items( )
Return the key,value pairs in order of the keys.