Package babel :: Module util :: Class odict

# Class odict

    object --+
             |
          dict --+
                 |
                odict

Ordered dict implementation.

See Also: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747

Instance Methods

    new empty dictionary

__init__(self, data=None) x.__init__(...) initializes x; see x.__class__.__doc__ for signature |

__delitem__(self, key) del x[y] |

__setitem__(self, key, item) x[i]=y |

an iterator over the keys of D

__iter__(self) iter(x) |

an iterator over the keys of D

iterkeys(self) iter(x) |

None

clear(self) Remove all items from D. |

a shallow copy of D

copy(self) |

list of D's (key, value) pairs, as 2-tuples

items(self) |

an iterator over the (key, value) items of D

iteritems(self) |

list of D's keys

keys(self) |

v, remove specified key and return the corresponding value

pop(self, key, default=missing) If key is not found, d is returned if given, otherwise KeyError is raised |

(k, v), remove and return some (key, value) pair as a

popitem(self, key) 2-tuple; but raise KeyError if D is empty. |

D.get(k,d), also set D[k]=d if k not in D

setdefault(self, key, failobj=None) |

None

update(self, dict) Update D from dict/iterable E and F. |

list of D's values

values(self) |

an iterator over the values of D

itervalues(self) |

Inherited from `dict`: `__cmp__`, `__contains__`, `__eq__`, `__ge__`, `__getattribute__`, `__getitem__`, `__gt__`, `__le__`, `__len__`, `__lt__`, `__ne__`, `__new__`, `__repr__`, `__sizeof__`, `fromkeys`, `get`, `has_key`, `viewitems`, `viewkeys`, `viewvalues` Inherited from `object`: `__delattr__`, `__format__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__str__`, `__subclasshook__`

Class Variables
Inherited from `dict`: `__hash__`

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, data=None)
(Constructor)

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Returns:

    new empty dictionary

Overrides: object.__init__
  (inherited documentation)

### __delitem__(self, key)
(Index deletion operator)

del x[y]

Overrides: dict.__delitem__
  (inherited documentation)

### __setitem__(self, key, item)
(Index assignment operator)

x[i]=y

Overrides: dict.__setitem__
  (inherited documentation)

### __iter__(self)

iter(x)

Returns: an iterator over the keys of D
Overrides: dict.__iter__
  (inherited documentation)

### iterkeys(self)

iter(x)

Returns: an iterator over the keys of D
Overrides: dict.iterkeys
  (inherited documentation)

### clear(self)

Remove all items from D.

Returns: None
Overrides: dict.clear
  (inherited documentation)

### copy(self)

Returns: a shallow copy of D
Overrides: dict.copy
  (inherited documentation)

### items(self)

Returns: list of D's (key, value) pairs, as 2-tuples
Overrides: dict.items
  (inherited documentation)

### iteritems(self)

Returns: an iterator over the (key, value) items of D
Overrides: dict.iteritems
  (inherited documentation)

### keys(self)

Returns: list of D's keys
Overrides: dict.keys
  (inherited documentation)

### pop(self, key, default=missing)

If key is not found, d is returned if given, otherwise KeyError is raised

Returns: v, remove specified key and return the corresponding value
Overrides: dict.pop
  (inherited documentation)

### popitem(self, key)

2-tuple; but raise KeyError if D is empty.

Returns: (k, v), remove and return some (key, value) pair as a
Overrides: dict.popitem
  (inherited documentation)

### setdefault(self, key, failobj=None)

Returns: D.get(k,d), also set D[k]=d if k not in D
Overrides: dict.setdefault
  (inherited documentation)

### update(self, dict)

Update D from dict/iterable E and F. If E has a .keys() method, does: for k in E: D[k] = E[k] If E lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

Returns: None
Overrides: dict.update
  (inherited documentation)

### values(self)

Returns: list of D's values
Overrides: dict.values
  (inherited documentation)

### itervalues(self)

Returns: an iterator over the values of D
Overrides: dict.itervalues
  (inherited documentation)