Advertisement
rfmonk

collections_deque_populating.py

Jan 9th, 2014
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. import collections
  5.  
  6. # Add to the right
  7. d1 = collections.deque()
  8. d1.extend('abcdefg')
  9. print 'extend   :', d1
  10. d1.append('h')
  11. print 'append   :', d1
  12.  
  13. # Add to the left
  14. d2 = collections.deque()
  15. d2.extendleft(xrange(6))
  16. print 'extendleft:', d2
  17. d2.appendleft(6)
  18. print 'appendleft:', d2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement