title: Python list rotation
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2150108/efficient-way-to-shift-a-list-in-python">Efficient way to shift a list in python</a>  </p>
  </blockquote>
  
  
  
  <p>I'd like to rotate a Python list by an arbitrary number of items to the right or left (the latter using a negative argument).</p>
  
  <p>Something like this:</p>
  
  <pre><code>&gt;&gt;&gt; l = [1,2,3,4]
  &gt;&gt;&gt; l.rotate(0)
  [1,2,3,4]
  &gt;&gt;&gt; l.rotate(1)
  [4,1,2,3]
  &gt;&gt;&gt; l.rotate(-1)
  [2,3,4,1]
  &gt;&gt;&gt; l.rotate(4)
  [1,2,3,4]
  </code></pre>
  
  <p>How might this be done?</p>