title: Python, trying to get file extension via URL
body: <p>I'm making an image grabber for the puush service; however, whenever I generate a random URL and attempt to verify it as a .PNG image, an error is generated. I just took up the Python language earlier today, so you could say I'm very new to this!</p>
  
  <p>The error that is generated:</p>
  
  <pre><code>Traceback (most recent call last):
    File "run.py", line 19, in &lt;module&gt;
      extension = guess_extension(guess_type(url))
    File "C:\Python33\lib\mimetypes.py", line 320, in guess_extension
      return _db.guess_extension(type, strict)
    File "C:\Python33\lib\mimetypes.py", line 189, in guess_extension
      extensions = self.guess_all_extensions(type, strict)
    File "C:\Python33\lib\mimetypes.py", line 168, in guess_all_extensions
      type = type.lower()
  AttributeError: 'tuple' object has no attribute 'lower'
  </code></pre>
  
  <p>The code that is ran:</p>
  
  <pre><code>#!/usr/bin/env python
  import sys
  import urllib
  from mimetypes import guess_type, guess_extension
  from random import choice
  
  randoms = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
             'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',' J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
             '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
  
  downloads = 1;
  
  #the number of files we want to download
  target = int(sys.argv[1]);
  
  while downloads &lt;= target:
      string = choice(randoms)+choice(randoms)+choice(randoms)+choice(randoms)+choice(randoms)
      url = 'http://puu.sh/'+string
  
      print(str(downloads)+': '+string)
  
      #download
      extension = guess_extension(guess_type(url))
      print(extension)
  
      #urllib.request('http://puu.sh/'+string, string+'.png')
      downloads += 1
  </code></pre>
  
  <p>Any ideas on what this error is attempting to tell me? Thanks.</p>