title: Python for loop with modulo
body: <p>Is it possible to create a python for-loop with a modulo operation? I have a ringbuffer in Python and I want to iterate the elements between the <code>startPos</code> and <code>endPos</code> indexes, where <code>startPos</code> can have a bigger value than <code>endPos</code>. In other programming languages, I would intuitively implement this with a modulo operator:</p>
  
  <pre><code>int startPos = 6;
  int endPos = 2;
  int ringBufferSize = 8;
  for(int i = startPos, i != endPos, i = (i+1) % ringBufferSize) {
      print buffer.getElementAt(i);
  }
  </code></pre>
  
  <p>Is there a way to do this easily in Python? I only found the</p>
  
  <pre><code>for i in list:
      print buffer[i]
  </code></pre>
  
  <p>Syntax but nothing which provides an equivalent solution to my problem.</p>
  
  <p>My next approach would be to create the list in advance before iterate the indexes which are stored in the list. But is there a way to do this as a one-liner like in other programming languages by using the modulo operation directly in the for loop?</p>