#NEWLINE# def OrderedDict_example( ) : #NEWLINE# #INDENT# ' show some examples for OrderedDict ' #NEWLINE# ' keep the order of insertion.\n        maintains a doubly linked list, so size is more than twice than normal dict' #NEWLINE# pairs = [ ( 'a' , 1 ) , ( 'b' , 2 ) , ( 'c' , 3 ) ] #NEWLINE# d1 = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( key , value ) in pairs : #NEWLINE# #INDENT# if ( key not in d1 ) : #NEWLINE# #INDENT# d1 [ key ] = [ ] #NEWLINE# #UNINDENT# d1 [ key ] . append ( value ) #NEWLINE# #UNINDENT# for key in d1 : #NEWLINE# #INDENT# print ( key , d1 [ key ] ) #NEWLINE# #UNINDENT# d2 = OrderedDict ( pairs ) #NEWLINE# for key in d2 : #NEWLINE# #INDENT# print ( key , d2 [ key ] )