title: Read/write class object in binary file?
body: <p>In my Python project, I'm using an object class <code>Forecast</code> with some attributes (temperature, humidity etc...). I want to use 2 scripts, one for writing the data into a binary file, one to read it.</p>
  <p>I tried both
  <code>f = open(file,&quot;wb&quot;) </code></p>
  <p><code>f.write(object)</code></p>
  <p>and</p>
  <p><code>pickle.dump(object, open(file,&quot;wb&quot;))</code></p>
  <p>but my problem is writing class objects with pickle won't let me read it properly with <code>pickle.load</code>,
  and <code>f.write</code> won't let me do this because 'bytes-like objects are required'.</p>
  <p>Can someone tell me if there is any other way to do it?</p>