Dict
index
c:\python25\lib\site-packages\schnolgo\dict.py

COPYRIGHT:
    this module is released under the gnu general public liscense. for more information, visit:
    http://www.gnu.org/copyleft/gpl.html
    
INFO:
    this module contains the Dict class, which contains two separate lists that represent
    keys and values as you would find in a regular python dictionary.
    the purpose of this class is to have dictionary-like access to key/value pairs
    while maintaining persistent index values.
    
    quoth howlin' wolf: "i'm built for comfort, i ain't built for speed."
    that is, this module shouldn't be used if you care about efficiency or any of that kind of nonsense.
    
    for information/bug/feature requests, please visit:
    http://sourceforge.net/projects/schnolgo/

 
Classes
       
__builtin__.object
Dict

 
class Dict(__builtin__.object)
    this class represents a dictionary with one special property: it exists so that there can be certainty about the 
indexes of the values represented in the dictionary, which can differ with some_dict.values(), etc. self.keys[x] will 
yeild the key corresponding to self.values[x], always.
 
NOTE: for some_dict[x]: if x is an int, this will yeild the value that's located at self.values[x]. if x is
a string, however, you can expect it to behave like a dict: it'll yeild the corresponding value, unless that key
appears more than once and you're expecting to see the value that corresponds with a later appearance of it.
 
ALSO NOTE: access to keys and values isn't exactly the same as normal dicts. you can access some_Dict.keys directly, which
can cause problems if you're not careful. this means BE CAREFUL when accessing self.values, self.keys.
 
  Methods defined here:
__contains__(self, key)
__delitem__(self, i)
__eq__(self, other)
__getitem__(self, i)
NOTE: this has changed since former schnolgo releases! please read!
if given an int, this function gives the equivalent to self.values[i].
if given a string, it is equivalent to some_dict['some_string'].
also see __setitem__() docstring
__init__(self, items=[], values=None)
__iter__(self)
i don't like this convention. i'd much rather have this return iteritems()
__len__(self)
__ne__(self, other)
__repr__(self)
__setitem__(self, i, val)
NOTE: this has changed since former schnolgo releases! please read!
for:
some_dict[i] = value #equivalent to self.values[i] = value
some_dict['foo'] = value #what you'd expect from a dict: the value corresponding to 'foo' now equals value
see notes at __getitem__() and notes for Dict as a whole.
append(self, key, value)
appends one key, value pair to the current Dict.
clear(self)
copy(self)
count(self, value)
note: counts self.values.
extend(self, items)
adds the items contained in the 'items' argument to the current Dict. if provided with a Dict, the .items() are appended to the current Dict. if provided with a tuple or list, the following format is expected: [('key1', val1), ('key2', val2), etc...]
has_key(self, k)
iindex(self, i)
returns the index of the key, value pair that correstponds with the (key, value) list/tuple argument provided
iindices(self, item)
returns a list containing all indices of items() corresponding to item
insert(self, index, item)
'item' is list, tuple, etc. index here is obviously an int
iremove(self, item_pair)
removes an item from keys, values, and dict, based on a (key, value) pair
items(self)
returns a list of tuples, where each tuple has the form ('key', value)
iteritems(self)
the values thrown by this iterator should have a dependable order. iterates over items()
iterkeys(self)
the values thrown by this iterator should have a dependable order.
note: THIS IS SERIOUSLY WHAT'S CALLED BY (for x in Dict)???
fuck that bullshit. this now equals itervalues.
itervalues(self)
the values thrown by this iterator should have a dependable order.
kindex(self, k)
returns the index of the key, value pair that corresponds with the given key. be careful when using keys, as they can be repeated in Dict.
kindices(self, k)
returns a list containing all indices of self.keys corresponding to k
kremove(self, key)
removes an item. takes a key argument. be careful about this, it may change index values... be careful that you know kindex(key) yeilds the result you want, in case there is more than one entry for that key.
pop(self, i)
removes the item at this_Dict[i] and returns the a tuple containing the (key, value) pair being removed.
reverse(self)
vindex(self, v)
returns the index of the key, value pair that corresponds with the given value. be careful when using this, obviously. 
there can always be more than one entry with the same value...
vindices(self, v)
returns a list containing all indices of self.values corresponding to v
vremove(self, val)
removes an item. takes a value argument. this is not an index, but a literal value
contained in self.values. be careful in case values are repeated.

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Dict' objects>
list of weak references to the object (if defined)