StringIO.readline() returns ''
Max
rabkin at mweb[DOT]co[DOT]za
Sun Apr 9 03:58:59 EDT 2006
I'm using StringIO for the first time (to buffer messages recieved from
a socket). I thought it would be a simple matter of writing the stuff to
the buffer and then calling readline, but that doesn't seem to work:
>>> buf = StringIO.StringIO()
>>> buf.write("Foo\n")
>>> buf.write("Bar\n")
>>> buf.flush()
>>> buf.readline()
''
I expected buf.readline() to return 'Foo\n'. What am I doing wrong?
--Max
More information about the Python-list
mailing list