[code.view]

[top] / python / PyMOTW / collections / collections_deque_rotate.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2008 Doug Hellmann All rights reserved.
     #
     """Manipulating the order of items in a deque.
     """
     
     __version__ = "$Id$"
     #end_pymotw_header
     
     import collections
     
     d = collections.deque(xrange(10))
     print 'Normal        :', d
     
     d = collections.deque(xrange(10))
     d.rotate(2)
     print 'Right rotation:', d
     
     d = collections.deque(xrange(10))
     d.rotate(-2)
     print 'Left rotation :', d
     

[top] / python / PyMOTW / collections / collections_deque_rotate.py

contact | logmethods.com