?

Log in

No account? Create an account

Previous Entry | Next Entry

Checking out Head First Programming

I'll write a complete review at some point, but just wanted to make a comment about the urllib.request exercise it has in Chapter 3.

If you are like me and starting to learn python, you may have downloaded the recommended 2.6.4 release and started mucking about with it. I first downloaded python when it was the 2.6.3 release so this may no longer be applicable, but it wasn't available within the first few lines when I did a search for the error:


Traceback (most recent call last):
File "test.py", line 1, in
import urllib.request
ImportError: No module named request

As the book Head First programming mentions in the intro, they are basing their code on 3.0 line of code. Download the latest release (3.1.1 at this time) and you will have no problem.

Comments

( 1 comment — Leave a comment )
(Anonymous)
Mar. 3rd, 2010 03:19 pm (UTC)
Hey I found your blog while searching for the same problem.Even I was stuck on chapter 2 due to this problem.I couldn't install python3 as its not packaged yet for Fedora 12.Anyways another workaround would be to write the code according to python 2.x :-
import urllib
page = urllib.urlopen("http://beans-r-us.biz/prices.html")
text = page.read().decode("utf8")
print(text)

As far as the book is concerned I'm loving it.Waiting for your review
-Abhishek
( 1 comment — Leave a comment )

Profile

golden gate bridge, ft point
sigje
Jennifer Davis
Website

Latest Month

February 2011
S M T W T F S
  12345
6789101112
13141516171819
20212223242526
2728