title: Saving and loading objects and using pickle
body: <p>I´m trying to save and load objects using <code>pickle</code> module. <br>
  First I declare my objects:</p>
  
  <pre><code>&gt;&gt;&gt; class Fruits:pass
  ...
  &gt;&gt;&gt; banana = Fruits()
  
  &gt;&gt;&gt; banana.color = 'yellow'
  &gt;&gt;&gt; banana.value = 30
  </code></pre>
  
  <p>After that I open a file called 'Fruits.obj'(previously I created a new .txt file and I renamed 'Fruits.obj'):</p>
  
  <pre><code>&gt;&gt;&gt; import pickle
  &gt;&gt;&gt; filehandler = open(b"Fruits.obj","wb")
  &gt;&gt;&gt; pickle.dump(banana,filehandler)
  </code></pre>
  
  <p>After do this I close my session and I began a new one and I put the next (trying to access to the object that it supposed to be saved):</p>
  
  <pre><code>file = open("Fruits.obj",'r')
  object_file = pickle.load(file)
  </code></pre>
  
  <p>But I have this message:</p>
  
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "C:\Python31\lib\pickle.py", line 1365, in load
  encoding=encoding, errors=errors).load()
  ValueError: read() from the underlying stream did notreturn bytes
  </code></pre>
  
  <p>I don´t know what to do because I don´t understand this message.
  Does anyone know How I can load my object 'banana'?
  Thank you!</p>
  
  <p><strong>EDIT:</strong>
  As some of you have sugested I put:</p>
  
  <pre><code>&gt;&gt;&gt; import pickle
  &gt;&gt;&gt; file = open("Fruits.obj",'rb')
  </code></pre>
  
  <p>There were no problem, but the next I put was:</p>
  
  <pre><code>&gt;&gt;&gt; object_file = pickle.load(file)
  </code></pre>
  
  <p>And I have error:</p>
  
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "C:\Python31\lib\pickle.py", line 1365, in load
  encoding=encoding, errors=errors).load()
  EOFError
  </code></pre>