title: Oscillating Values in Python
body: <p>So I need to have 2 values oscillate back and forth.
  Say <code>2</code> the first time, and <code>4</code> the second time. Repeat from the top.</p>
  
  <p>So I wrote the below generator function which works. Each time it is called via <code>next</code> it returns the subsequent value, and then repeats from the top.</p>
  
  <p>For the sake of learning, and improving, NOT opinion, is there a better way? In Python there always seems to be a better way, and I like to learn them so as to improve my skills.</p>
  
  <p>The "main code" is just to show an example of the generator, oscillator, in use, and is not the primary use of the oscillator.</p>
  
  <pre><code>## Main code
  go_Osci = g_Osci()
  for i in xrange(10):
      print("Value: %i") %(go_Osci.next())
  
  ## Generator
  def g_Osci():
      while True:
          yield 2
          yield 4
  </code></pre>