ordereddict = oDict({'a' : 1, 'b' : 2}, True) The dictionary can be
initialised with an optional dictionary passed in as the first argument,
You can also pass in an order parameter which chooses the sort method.
order=True (default) means all ordered methods use the normal sort
function. order=False means all ordered methods use the reverse sort
function. order=None means no sort function.
keys, items, iter and pop methods are ordered - based on the key. The
ordering is implemented in the keys() function. The iterators are
returned using the custom iterator dIter (which will work in three
different ways).
|
|
|
__setitem__(self,
item,
value)
Setting a keyword |
source code
|
|
|
|
|
|
|
|
|
popitem(self)
Emulates the popitem method - pops the first one in the list based on
the chosen sort method. |
source code
|
|
|
has_key(self,
item)
Does the dictionary have this key. |
source code
|
|
|
__contains__(self,
item)
Does the dictionary have this key. |
source code
|
|
|
setdefault(self,
item,
default=None)
Fetch an item if it exists, otherwise set the item to default and
return default. |
source code
|
|
|
get(self,
item,
default=None)
Fetch the item if it exists, otherwise return default. |
source code
|
|
|
update(self,
indict)
Update the current oDdict with the dictionary supplied. |
source code
|
|
|
copy(self)
Create a new oDict object that is a copy of this one. |
source code
|
|
|
dict(self)
Create a dictionary version of this oDict. |
source code
|
|
|
|
|
__repr__(self)
An oDict version of __repr__ |
source code
|
|
|
keys(self)
Return an ordered list of the keys of this oDict. |
source code
|
|
|
items(self)
Like keys() but returns a list of (key, value) |
source code
|
|
|
values(self)
Like keys() but returns an ordered list of values (ordered by key) |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__hash__(self)
This just raises a TypeError. |
source code
|
|
|
__iter__(self)
Return an ordered iterator for the oDict. |
source code
|
|
|
iteritems(self)
Return an ordered iterator over the the oDict - returning (key,
value) tuples. |
source code
|
|
|
iterkeys(self)
Return an ordered iterator over the keys the oDict. |
source code
|
|
|
itervalues(self)
Return an ordered iterator over the the values of the oDict - ordered
by key. |
source code
|
|
|
|