title: Trying to write a cPickle object but get a 'write' attribute type error
body: <p>When trying to apply some code I found on the internet in iPython, it's coming up with an error:</p>
  
  <pre><code>TypeError                                 Traceback (most recent call last)
      &lt;ipython-input-4-36ec95de9a5d&gt; in &lt;module&gt;()
       13     all[i] = r.json()
       14 
  ---&gt; 15 cPickle.dump(all, outfile)
  
  TypeError: argument must have 'write' attribute
  </code></pre>
  
  <p>Here's what I have done in order:</p>
  
  <pre><code>outfile = "C:\John\Footy Bants\R COMPLAEX MATHS"
  </code></pre>
  
  <p>Then, I pasted in the following code:</p>
  
  <pre><code>import requests, cPickle, shutil, time
  
  all = {}
  errorout = open("errors.log", "w")
  
  for i in range(600):
      playerurl = "http://fantasy.premierleague.com/web/api/elements/%s/"
      r = requests.get(playerurl % i)
  
      # skip non-existent players
      if r.status_code != 200: continue
  
      all[i] = r.json()
  
  cPickle.dump(all, outfile)
  </code></pre>
  
  <p>Here's the original article to give you an idea of what I'm trying to achieve:</p>
  
  <p><a href="http://billmill.org/fantasypl/">http://billmill.org/fantasypl/</a></p>