#format python import unittest class SeqDict(dict): """dictionary that perserve the setted sequence """ def __init__(self): self._seq=list() def __setitem__(self, key, value): self._seq.append(key) dict.__setitem__(self, key, value) def keys(self): return self._seq def values(self): result=list() for key in self.keys(): result.append(self[key]) return result class SeqDictTest(unittest.TestCase): def test1(self): sd = SeqDict() sd['one'] = 1 sd['two'] = 2 sd['three'] = 3 self.assertEquals(['one','two','three'], sd.keys()) self.assertEquals([1,2,3], sd.values()) class ValueSizedSeqDict(SeqDict): """To be continue...""" if __name__=='__main__': unittest.main(argv=('','-v'))