query uniprot via REST web service using Python

import urllib2
import traceback

dbName = "swissprot"
id = "HBA_HUMAN"
format = "uniprot"
urlBase = "http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/"
urlFinal = urlBase + dbName + "/" + id + "/" + format
print "URL is: " + urlFinal
try:
    response = urllib2.urlopen(urlFinal).read()
    print "Received " + str((len(response.splitlines()))) + " lines"
    print response
except Exception as err:
    traceback.print_tb(err.__traceback__)