title: How the write(), read() and getvalue() methods of Python io.BytesIO work?
body: <p>I'm trying to understand the <strong>write()</strong> and <strong>read()</strong> methods of <strong>io.BytesIO</strong>.
  My understanding was that I could use the <strong>io.BytesIO</strong> as I would use a File 
  object.</p>
  
  <pre><code>import io
  in_memory = io.BytesIO(b'hello')
  print( in_memory.read() )
  </code></pre>
  
  <p>The above code will return <em>b'hello'</em> as expected, but the code below will return an empty string <em>b''</em>.</p>
  
  <pre><code>import io
  in_memory = io.BytesIO(b'hello')
  in_memory.write(b' world')
  print( in_memory.read() )
  </code></pre>
  
  <p>My questions are:</p>
  
  <p>-What is <code>io.BytesIO.write(b' world')</code> doing exactly?</p>
  
  <p>-What is the difference between <strong>io.BytesIO.read()</strong> and <strong>io.BytesIO.getvalue()</strong>?</p>
  
  <p>I assume that the answer is related to <strong>io.BytesIO</strong> being a stream object, but the big picture is not clear to me.</p>