"iddwb" <iddwb at imap1.asu.edu> wrote in message news:Pine.LNX.4.21.0104180243040.6996-100000 at moroni.pp.asu.edu... > I've tried again with a formulation from Guido's intro to web > programming. Here's the error.. > > ===================================== > Traceback (most recent call last): > File "./html3", line 46, in ? > htmlbuffer.feed(buffer) > File "/usr/local/lib/python1.6/sgmllib.py", line 82, in feed > self.rawdata = self.rawdata + data > TypeError: illegal argument type for built-in operation > > =================================== > buffer = f.readlines() > f.close() > htmlbuffer.feed(buffer) > htmlbuffer.close() f.readlines() returns a list of strings (one for each line in the input file), but htmlbuffer.feed is expecting one big string. The solution is to do this instead: buffer = f.read() This will read the entire HTML file into a single string. More on lists: http://diveintopython.org/odbchelper_list.html More on file methods: http://diveintopython.org/fileinfo_files.html More on why you should upgrade to Python 2.0: http://www.amk.ca/python/2.0/ Hope this helps. -M You're smart; why haven't you learned Python yet? http://diveintopython.org/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4