fileobj.write(buffer(...))

Tomasz Lisowski lisowski.tomasz at sssa.NOSPAM.com.pl
Thu Feb 22 03:33:53 EST 2001


Uzytkownik "Niki Spahiev" <spahievi at vega.bg> napisal w wiadomosci
news:mailman.982795168.21257.python-list at python.org...
> Is this working as expected?
>
> >>> open( 'test', 'w' ).write( buffer( 'abcd', 2 ) )
> >>> from cStringIO import StringIO
> >>> StringIO().write( buffer( 'abcd', 2 ) )
> Traceback (innermost last):
>   File "<pyshell#4>", line 1, in ?
>     StringIO().write( buffer( 'abcd', 2 ) )
> SystemError: bad argument to internal function

What about closing the file? Since you do not have a reference to the file
object, you are not able to close it. Perhaps it would be better to write:

>>> f=open( 'test', 'w' )
>>> f.write( buffer( 'abcd', 2 ) )
>>> f.close()

Don't know about StringIO, sorry :-(

Tomasz





More information about the Python-list mailing list