A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/112911.html below:

syntax from diveintopython

syntax from diveintopython syntax from diveintopythonMark Pilgrim f8dy at yahoo.com
Wed Apr 18 10:39:01 EDT 2001
"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/




More information about the Python-list mailing list

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