I'm trying to create a library for the Last.fm webservice[1] and the first thing I created was a class for the Profile Information.[2] Is this the proper way of creating it? Is this useful to another programmer?
import urllib import xml.etree.ElementTree as ET from BeautifulSoup import BeautifulStoneSoup as BSS BASEURL = 'http://ws.audioscrobbler.com/1.0/user/' class UserProfile(object): """Represents the user profile data""" def __init__(self, username): """Give the username""" self.username = username def getxmldata(self): url = BASEURL + self.username + '/profile.xml' self.xmldata = urllib.urlopen(url).read() def parsedata(self): soup = BSS(self.xmldata) self.url = soup.url.string self.realname = soup.realname.string self.sha1 = soup.mbox_sha1sum.string self.regdate = soup.registered.string self.unixregdate = soup.registered['unixtime'] self.age = soup.age.string self.gender = soup.gender.string self.country = soup.country.string self.playcount = soup.playcount.string self.avatar = soup.avatar.string self.icon = soup.icon.string self.id = soup.profile['id'] Also, how do I then begin to approach the whole API ? Do I create a User class the inherits from the UserProfile class and other classes for their Neighbours', Top Artists, etc ? Do a create a separate class for each web service ? I have never coded something like this before and all advice is welcome. [1] http://www.audioscrobbler.net/data/webservices/ [2] http://ws.audioscrobbler.com/1.0/user/RJ/profile.xml _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor