collections :: OrderedDict :: Class OrderedDict
[frames] | no frames]

Class OrderedDict

object --+    
         |    
      dict --+
             |
            OrderedDict

Dictionary that remembers insertion order

Instance Methods
 
__delitem__(od, y)
del od[y]
 
__eq__(od, y)
od==y.
new empty dictionary

__init__(self, *args, **kwds)
Initialize an ordered dictionary.
 
__iter__(od)
iter(od)
 
__ne__(od, y)
od!=y
 
__reduce__(self)
Return state information for pickling
 
__repr__(od)
repr(od)
 
__reversed__(od)
reversed(od)
 
__setitem__(od, i, y)
od[i]=y
None
clear(od)
Remove all items from od.
a shallow copy of od
copy(od)
list of (key, value) pairs in od
items(od)
an iterator over the (key, value) items of D
iteritems(self)
od.iteritems -> an iterator over the (key, value) pairs in od
an iterator over the keys in od
iterkeys(od)
an iterator over the values of D
itervalues(self)
od.itervalues -> an iterator over the values in od
list of keys in od
keys(od)
v, remove specified key and return the corresponding
pop(od, k, d=...)
value.
(k, v), return and remove a (key, value) pair
popitem(od)
Pairs are returned in LIFO order if last is true or FIFO order if false.
od.get(k,d), also set od[k]=d if k not in od
setdefault(od, k, d=...)
None
update(*args, **kwds)
Update D from dict/iterable E and F.
list of values in od
values(od)
a set-like object providing a view on od's items
viewitems(od)
a set-like object providing a view on od's keys
viewkeys(od)
an object providing a view on od's values
viewvalues(od)

Inherited from dict: __cmp__, __contains__, __ge__, __getattribute__, __getitem__, __gt__, __le__, __len__, __lt__, __new__, __sizeof__, get, has_key

Inherited from object: __delattr__, __format__, __reduce_ex__, __setattr__, __str__, __subclasshook__

Class Methods
New ordered dictionary with keys from S
fromkeys(OD, S, v=...)
If not specified, the value defaults to None.
Class Variables

Inherited from dict: __hash__

Properties

Inherited from object: __class__

Method Details

__delitem__(od, y)
(Index deletion operator)

 

del od[y]

Overrides: dict.__delitem__

__eq__(od, y)
(Equality operator)

 

od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive.

Overrides: dict.__eq__

__init__(self, *args, **kwds)
(Constructor)

 

Initialize an ordered dictionary. The signature is the same as regular dictionaries, but keyword arguments are not recommended because their insertion order is arbitrary.

Returns:
new empty dictionary

Overrides: object.__init__

__iter__(od)

 

iter(od)

Overrides: dict.__iter__

__ne__(od, y)

 

od!=y

Overrides: dict.__ne__

__reduce__(self)

 

Return state information for pickling

Overrides: object.__reduce__

__repr__(od)
(Representation operator)

 

repr(od)

Overrides: object.__repr__

__setitem__(od, i, y)
(Index assignment operator)

 

od[i]=y

Overrides: dict.__setitem__

clear(od)

 

Remove all items from od.

Returns: None
Overrides: dict.clear

copy(od)

 
Returns: a shallow copy of od
Overrides: dict.copy

fromkeys(OD, S, v=...)
Class Method

 

If not specified, the value defaults to None.

Returns: New ordered dictionary with keys from S
Overrides: dict.fromkeys

items(od)

 
Returns: list of (key, value) pairs in od
Overrides: dict.items

iteritems(self)

 

od.iteritems -> an iterator over the (key, value) pairs in od

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

iterkeys(od)

 
Returns: an iterator over the keys in od
Overrides: dict.iterkeys

itervalues(self)

 

od.itervalues -> an iterator over the values in od

Returns: an iterator over the values of D
Overrides: dict.itervalues

keys(od)

 
Returns: list of keys in od
Overrides: dict.keys

pop(od, k, d=...)

 

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

Returns: v, remove specified key and return the corresponding
Overrides: dict.pop

popitem(od)

 

Pairs are returned in LIFO order if last is true or FIFO order if false.

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

setdefault(od, k, d=...)

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

update(*args, **kwds)

 

Update D from dict/iterable E and F. If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and 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(od)

 
Returns: list of values in od
Overrides: dict.values

viewitems(od)

 
Returns: a set-like object providing a view on od's items
Overrides: dict.viewitems

viewkeys(od)

 
Returns: a set-like object providing a view on od's keys
Overrides: dict.viewkeys

viewvalues(od)

 
Returns: an object providing a view on od's values
Overrides: dict.viewvalues