title: Urlretrieve give local_file name from a variable
body: <p>I have a really irritating problem.</p>
  
  <p>I'm using Python to open a URL link which is a pdf file and i want to save it in my local folder.</p>
  
  <p>My code :</p>
  
  <pre><code>urlPath = 'http://example.com/test.pdf'
  myFile = urlopen(urlPath)
  urllib.urlretrieve(myFile.url, myFile.url)
  </code></pre>
  
  <p>Error message:</p>
  
  <pre><code>tfp = open(filename, 'wb')
  IOError: [Errno 22] invalid mode ('wb') or filename: 
  </code></pre>
  
  <p>I have tried to use to code below and everythin works fine, my file stored correctly.</p>
  
  <pre><code>urlPath = 'http://example.com/test.pdf'
  myFile = urlopen(urlPath)
  urllib.urlretrieve(myFile.url, 'myFile.pdf')
  </code></pre>
  
  <p>What does i'm writing wrong?</p>