title: Python StreamIO reading and writing from the same stream
body: <p>I'm looking for a pythonic means of both reading and writing to a stream (in the IOBase hierarchy) without having to manage the stream position via seek() and tell().  This would be similar to how a socket stream would be expected to work where the receiving end would be able to continuously read while bytes where being received.</p>
  
  <p>I've tried using a BufferedReader and BufferedWriter both attached to the same raw stream, but operations on one affect the stream position on the other.  seek()/tell() appear to pass directly through to the underlying raw stream.  Are there other IOBase types that can be used to act effectively as an IO stream where concurrent input and output are supported without the need to manage the stream position (similar to C++ stringstream >> and &lt;&lt; ).</p>
  
  <p>Thanks!</p>
  
  <pre><code>&gt;&gt;&gt; import io
  &gt;&gt;&gt; buf = io.BytesIO()
  &gt;&gt;&gt; r = io.BufferedReader(buf)
  &gt;&gt;&gt; w = io.BufferedWriter(buf)
  &gt;&gt;&gt; w.write('foo bar')
  7L
  &gt;&gt;&gt; r.read(1)
  ''
  &gt;&gt;&gt; r.tell()
  0L
  &gt;&gt;&gt; w.flush()
  &gt;&gt;&gt; r.tell()
  7L
  &gt;&gt;&gt; r.flush()
  &gt;&gt;&gt; r.tell()
  7L
  &gt;&gt;&gt; w.tell()
  7L
  &gt;&gt;&gt; buf.tell()
  7L
  </code></pre>