Home | Trees | Index | Help |
---|
|
object --+ | dict --+ | opdict
Minimal order preserving dictionary. Uses a list of keys in addition to an internal dictionary to keep track of the order in which entries are added to the dictionary. Calls to keys(), values(), items(), iterkeys(), itervalues() and iteritems() and popitem() will return data in the order that it was added to the dictionary.
This class is intended as a drop in replacement for the builtin dict type and replicates all its methods. While the internal representation would enable the addition of mutable sequence methods such as slices these have not (yet) been implemented.
The motivation for creating this class was to stop the standard library ConfigParser module randomising the order of sections and options when saving modified configs back to a file.
Anthony Horton horton@ast.cam.ac.uk 20050216
|
|||
__init__(self,
arg={},
**kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature |
|||
__delitem__(self,
key)
del x[y] |
|||
__setitem__(self,
key,
value)
x[i]=y |
|||
__iter__(self)
iter(x) |
|||
__str__(self)
str(x) |
|||
__repr__(self)
repr(x) |
|||
keys(self) | |||
values(self) | |||
items(self) | |||
iterkeys(self) | |||
itervalues(self) | |||
iteritems(self) | |||
update(self,
opd)
Update D from E: for k in E.keys(): D[k] = E[k] |
|||
pop(self,
key,
default=None)
If key is not found, d is returned if given, otherwise KeyError is raised |
|||
popitem(self)
2-tuple; but raise KeyError if D is empty |
|||
copy(self) | |||
clear(self)
Remove all items from D. |
|||
fromkeys(keys,
value=None)
v defaults to None. |
|||
setdefault(self, key, default=None) | |||
Inherited from Inherited from |
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Home | Trees | Index | Help |
---|
Generated by Epydoc 3.0alpha2 on Sun Jun 11 16:26:28 2006 | http://epydoc.sf.net |