| |
- __builtin__.dict(__builtin__.object)
-
- opdict
class opdict(__builtin__.dict) |
|
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 |
|
- Method resolution order:
- opdict
- __builtin__.dict
- __builtin__.object
Methods defined here:
- __delitem__(self, key)
- __init__(self, arg={}, **kwargs)
- __iter__(self)
- __repr__(self)
- __setitem__(self, key, value)
- __str__(self)
- clear(self)
- copy(self)
- fromkeys(keys, value=None)
- items(self)
- iteritems(self)
- iterkeys(self)
- itervalues(self)
- keys(self)
- pop(self, key, default=None)
- popitem(self)
- setdefault(self, key, default=None)
- update(self, opd)
- values(self)
Data and other attributes defined here:
- __dict__ = <dictproxy object>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'opdict' objects>
- list of weak references to the object (if defined)
Methods inherited from __builtin__.dict:
- __cmp__(...)
- x.__cmp__(y) <==> cmp(x,y)
- __contains__(...)
- x.__contains__(y) <==> y in x
- __eq__(...)
- x.__eq__(y) <==> x==y
- __ge__(...)
- x.__ge__(y) <==> x>=y
- __getattribute__(...)
- x.__getattribute__('name') <==> x.name
- __getitem__(...)
- x.__getitem__(y) <==> x[y]
- __gt__(...)
- x.__gt__(y) <==> x>y
- __hash__(...)
- x.__hash__() <==> hash(x)
- __le__(...)
- x.__le__(y) <==> x<=y
- __len__(...)
- x.__len__() <==> len(x)
- __lt__(...)
- x.__lt__(y) <==> x<y
- __ne__(...)
- x.__ne__(y) <==> x!=y
- get(...)
- D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- has_key(...)
- D.has_key(k) -> True if D has a key k, else False
Data and other attributes inherited from __builtin__.dict:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
| |