# # This example works with Python 2.2. class MyDict_for_python_22(dict): def __init__(self, **kw): for key in kw.keys(): self[key] = kw[key] def show(self): print 'Showing example for Python 2.2 ...' for key in self.keys(): print 'key: %s value: %s' % (key, self[key]) def test_for_python_22(): d = MyDict_for_python_22(one=11, two=22, three=33) d.show() test_for_python_22() # # This example works with Python 2.3. # Keyword support, when subclassing dictionaries, seems to have # been enhanced in Python 2.3. class MyDict(dict): def show(self): print 'Showing example for Python 2.3 ...' for key in self.keys(): print 'key: %s value: %s' % (key, self[key]) def test(): d = MyDict(one=11, two=22, three=33) d.show() test()