Advertisement
rfmonk

collections_ordereddict_iter.py

Jan 10th, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. import collections
  5.  
  6. print 'Regular dictionary:'
  7. d = {}
  8. d['a'] = 'A'
  9. d['b'] = 'B'
  10. d['c'] = 'C'
  11.  
  12. for k, v in d.items():
  13.     print k, v
  14.  
  15. print '\nOrderedDict:'
  16. d = collections.OrderedDict()
  17. d['a'] = 'A'
  18. d['b'] = 'B'
  19. d['c'] = 'C'
  20.  
  21. for k, v in d.items():
  22.     print k, v
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement