title: How to generate an alternating range?
body: <p>I need to search for an item in a list around a given index with in a given radius. Currently I use this function to generate alternating offsets for the search:</p>
  
  <pre><code>def generateSearchIndizes(radius):
      for i in range(1, radius + 1):
          yield i
          yield -i
  </code></pre>
  
  <p>The code that does the search looks something like this:</p>
  
  <pre><code>for i in generateSearchIndizes():
      if pred(myList[baseIndex + i]):
          result = myList[baseIndex + i]
          break # terminate search when first item is found
  </code></pre>
  
  <p>My question is, is there a more elegant way to generate the search indizes, maybe without defining a special function?</p>