title: python: TypeError: can't write str to text stream
body: <p>I must be doing something obviously wrong here. But what is it, and how do I fix?</p>
  
  <pre><code>Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on
  win32
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import io
  &gt;&gt;&gt; f1 = io.open('test.txt','w')
  &gt;&gt;&gt; f1.write('bingo')
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "c:\appl\python\2.6.5\lib\io.py", line 1500, in write
      s.__class__.__name__)
  TypeError: can't write str to text stream
  </code></pre>
  
  <p><strong>edit</strong>: In my real application, I won't have a constant string, I'll have a regular string... if unicode is the issue, how do I convert to what io.open requires?</p>