Package grizzled :: Package collections :: Module dict :: Class OrderedDict
[hide private]
[frames] | no frames]

Class OrderedDict

source code

object --+    
         |    
      dict --+
             |
            OrderedDict

OrderedDict is a simple ordered dictionary. The keys(), items(), __iter__(), and other methods all return the keys in the order they were added to the dictionary. Note that re-adding a key (i.e., replacing a key with a new value) does not change the original order.

An OrderedDict object is instantiated with exactly the same parameters as a dict object. The methods it provides are identical to those in the dict type and are not documented here.

Instance Methods [hide private]
new empty dictionary

__init__(self, *args, **kw)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__setitem__(self, key, value)
x[i]=y
source code
 
__delitem__(self, key)
del x[y]
source code
 
__iter__(self)
iter(x)
source code
 
__str__(self)
str(x)
source code
list of D's keys
keys(self) source code
list of D's (key, value) pairs, as 2-tuples
items(self) source code
list of D's values
values(self) source code
an iterator over the (key, value) items of D
iteritems(self) source code
an iterator over the keys of D
iterkeys(self) source code
None
update(self, d)
Update D from dict/iterable E and F.
source code
v, remove specified key and return the corresponding value
pop(self, key, default=None)
If key is not found, d is returned if given, otherwise KeyError is raised
source code
(k, v), remove and return some (key, value) pair as a
popitem(self)
2-tuple; but raise KeyError if D is empty.
source code

Inherited from dict: __cmp__, __contains__, __eq__, __ge__, __getattribute__, __getitem__, __gt__, __le__, __len__, __lt__, __ne__, __new__, __repr__, __sizeof__, clear, copy, fromkeys, get, has_key, itervalues, setdefault, viewitems, viewkeys, viewvalues

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

Class Variables [hide private]

Inherited from dict: __hash__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

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

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Returns:
new empty dictionary

Overrides: object.__init__
(inherited documentation)

__setitem__(self, key, value)
(Index assignment operator)

source code 

x[i]=y

Overrides: dict.__setitem__
(inherited documentation)

__delitem__(self, key)
(Index deletion operator)

source code 

del x[y]

Overrides: dict.__delitem__
(inherited documentation)

__iter__(self)

source code 

iter(x)

Overrides: dict.__iter__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

keys(self)

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

items(self)

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

values(self)

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

iteritems(self)

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

iterkeys(self)

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

update(self, d)

source code 

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)

pop(self, key, default=None)

source code 

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)

source code 

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)