I do not regularly access Uniprot from Python, but just today solved a matching Rosalind task. My solution uses the urllib library to download the data:
import urllib code = "Q7Z7W5" data = urllib.urlopen("http://www.uniprot.org/uniprot/" + code + ".txt").read()
And then uses
split() to process the file line by line. Each line has some structure and starts with a two character code, like "DR". The content of the lines is reasonably well structured, and, as the Rosalind task requires, allows you to extract GO ontology term annotation.