cStringIO & write error?
Alex
cut_me_out at hotmail.com
Sat Jul 29 13:55:49 EDT 2000
> When I do:
>
> from StringIO import StringIO
> f=open('file.dat', 'r+b')
> ff=StringIO(f.read(-1))
> ff.seek(0,0)
> ff.write(chr(123))
>
> all is ok. But when I import from cStringIO I get an error:
>
[snip]
> AttributeError: write
>
> What am I doing wrong?
Probably nothing -- I ran into a similar incompatibility between
cStringIO and StringIO a little while back. I think I got around it by
doing stuff like this:
>>> from cStringIO import StringIO
>>> t = StringIO()
>>> t.write('stuff')
>>> t.seek(0)
>>> t.read()
'stuff'
Alex.
More information about the Python-list
mailing list