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

__init__(self, data=`{``'``territory_zones``'``:` `{``'``001``'``:` `[``'``Etc/GMT``'``,` `'``Etc/GMT-1``'``,` `'``Etc/GMT-``...`) x.__init__(...) initializes x; see x.__class__.__doc__ for signature |

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

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

__iter__(self) iter(x) |

clear(self) Remove all items from D. |

copy(self) Returns: a shallow copy of D |

items(self) Returns: list of D's (key, value) pairs, as 2-tuples |

keys(self) Returns: list of D's keys |

pop(self, key, default=`{``'``territory_zones``'``:` `{``'``001``'``:` `[``'``Etc/GMT``'``,` `'``Etc/GMT-1``'``,` `'``Etc/GMT-``...`) If key is not found, d is returned if given, otherwise KeyError is raised |

setdefault(self, key, failobj=`{``'``territory_zones``'``:` `{``'``001``'``:` `[``'``Etc/GMT``'``,` `'``Etc/GMT-1``'``,` `'``Etc/GMT-``...`) Returns: D.get(k,d), also set D[k]=d if k not in D |

update(self, dict) Update D from E and F: for k in E: D[k] = E[k] (if E has keys else: for (k, v) in E: D[k] = v) then: for k in F: D[k] = F[k] |

values(self) Returns: list of D's values |

Inherited from `dict`: `__cmp__`, `__contains__`, `__eq__`, `__ge__`, `__getattribute__`, `__getitem__`, `__gt__`, `__hash__`, `__le__`, `__len__`, `__lt__`, `__ne__`, `__new__`, `__repr__`, `fromkeys`, `get`, `has_key`, `iteritems`, `iterkeys`, `itervalues`, `popitem` Inherited from `object`: `__delattr__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__str__`

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, data=`{``'``territory_zones``'``:` `{``'``001``'``:` `[``'``Etc/GMT``'``,` `'``Etc/GMT-1``'``,` `'``Etc/GMT-``...`)
(Constructor)

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

Returns:

      new empty dictionary

Overrides: dict.__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)

Overrides: dict.__iter__
  (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)

### keys(self)

Returns:

      list of D's keys

Overrides: dict.keys
  (inherited documentation)

### pop(self, key, default=`{``'``territory_zones``'``:` `{``'``001``'``:` `[``'``Etc/GMT``'``,` `'``Etc/GMT-1``'``,` `'``Etc/GMT-``...`)

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)

### setdefault(self, key, failobj=`{``'``territory_zones``'``:` `{``'``001``'``:` `[``'``Etc/GMT``'``,` `'``Etc/GMT-1``'``,` `'``Etc/GMT-``...`)

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 E and F: for k in E: D[k] = E[k] (if E has keys else: for (k, v) in E: D[k] = v) then: 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)