title: creating stream to iterate over from string in Python
body: <p>I want to create a stream from a string in Python so that it's equivalent to reading the string as if it's read from a text file. something like:</p>
  
  <pre><code>for line in open('myfile.txt'): print line
  </code></pre>
  
  <p>except the contents of 'myfile.txt' are stored in a string <code>s</code>. Is this the correct/best way to do it?</p>
  
  <pre><code>s = StringIO.StringIO("a\t\b\nc\td\n")
  for line in s: print line
  </code></pre>