I'm currently trying out some of the code from the book called, "Programming Collective Intelligence" and I ran into this error cause by pydelicious.py. Can anyone tell me how to debug such problems?
Python Code:
def initializeUserDict(tag, count = 5):
user_dict = {}
#get the top count' popular posts
for p1 in get_popular(tag = tag)[0:count]:
#find all users who posted this
for p2 in get_urlposts(p1['href']):
user = p2['user']
user_dict[user] = {}
return user_dict
Error:
>>>from deliciousrec import *
>>>delusers = initializeUserDict('programming')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "deliciousrec.py", line 9, in initializeUserDict
for p2 in get_urlposts(p1['href']):
KeyError: 'href'
p1:
for p1 in get_popular(tag = 'python')[0:5]:
print p1
{'extended': u'', 'description': u'20.19. SimpleHTTPServer \u2014 Simple HTTP request handler \u2014 Python v2.7.7 documentation', 'tags': u'http', 'url': u'https://docs.python.org/2/library/simplehttpserver.html', 'user': u'', 'dt': ''}
{'extended': u'', 'description': u'Must Have Python Packages | Algorithm.co.il', 'tags': u'python', 'url': u'http://www.algorithm.co.il/blogs/programming/must-have-python-packages/', 'user': u'', 'dt': ''}
{'extended': u'', 'description': u'Le blog de Thomas Blanchard: Configure pydistutils.cfg - example python distutils config file', 'tags': u'distutils', 'url': u'http://bouktin.blogspot.be/2012/04/configure-pydistutilscfg-python.html', 'user': u'', 'dt': ''}
{'extended': u'', 'description': u'3.2 Installation', 'tags': u'cheetah', 'url': u'http://www.cheetahtemplate.org/docs/users_guide_html_multipage/gettingStarted.install.html', 'user': u'', 'dt': ''}
{'extended': u'', 'description': u"How can I represent an 'Enum' in Python? - Stack Overflow", 'tags': u'enum', 'url': u'http://stackoverflow.com/questions/36932/how-can-i-represent-an-enum-in-python?rq=1', 'user': u'', 'dt': ''}