Package Ganga :: Package Utility :: Package external :: Module ordereddict :: Class oDict
[hide private]
[frames] | no frames]

Class oDict

source code

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).

Instance Methods [hide private]
 
__init__(self, indict={}, order=True) source code
 
__setitem__(self, item, value)
Setting a keyword
source code
 
__getitem__(self, item)
Fetching a value.
source code
 
__delitem__(self, item)
Deleting a keyword
source code
 
pop(self, item=[], default=None)
Emulates the pop method.
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
 
clear(self)
Clear 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
 
__len__(self) source code
 
__cmp__(self, other) source code
 
__eq__(self, other) source code
 
__ne__(self, other) source code
 
__gt__(self, other) source code
 
__ge__(self, other) source code
 
__lt__(self, other) source code
 
__le__(self, other) 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
 
__str__(self)
An oDict version of __str__
source code
Class Methods [hide private]
 
fromkeys(cls, *args)
Return a new oDict initialised from the values supplied.
source code
Class Variables [hide private]
  __doc__ = """ordereddict = oDict({'a' : 1, 'b' : 2}, Tr...
Method Details [hide private]

pop(self, item=[], default=None)

source code 

Emulates the pop method. If item is not supplied it pops the first value in the dictionary. This is different from the normal dict pop method.

fromkeys(cls, *args)
Class Method

source code 

Return a new oDict initialised from the values supplied. If sys.version_info > 2.2 this becomes a classmethod.


Class Variable Details [hide private]

__doc__

Value:
"""ordereddict = oDict({'a' : 1, 'b' : 2}, True)
The dictionary can be initialised with an optional dictionary passed i\
n 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 fun\
ction.
order=False  means all ordered methods use the reverse sort function.
order=None means no sort function.
...