Maybe this short interactive session can give you an idea why.

>>> from StringIO import StringIO
>>> b = StringIO("123456789")
>>> b.tell()
0
>>> b.write("abc")
>>> b.getvalue()
'abc456789'
>>> b.tell()
3

StringIO seems to operate like a file opened with "r+" (If I've got my modes
right): it is opened for reading and writing, and positioned at the beginning.
In my example, the write of 3 bytes overwrites the first 3 bytes of the file
and leaves the rest intact.  In your example your first write overwrote the
whole initial contents of the file, so you couldn't notice this effect.

Jeff

Attachment: pgpYWXEucN3cQ.pgp
Description: PGP signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to