StringIO readline() bug??

fredrik at pythonware.com fredrik at pythonware.com
Fri Oct 13 07:50:27 EDT 2000


Alex wrote:
> Here's your error: StringIo needs to be initialized with
> a string, not with a list of strings, which is what you're
> giving it here.
>
> Use, instead:
>
> >>> fstr = StringIO(file.readline())

better make that:

>>> fstr = StringIO(file.read())

> Note the difference: file.readline() returns the file's
> contents as a single string; file.readlines() returns
> it as a list of strings (one per line).

readline() reads a single line, read() (without
arguments) reads until end of file.

</F>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list