Surprising difference between StringIO.StringIO and io.StringIO

Peter Otten __peter__ at web.de
Fri May 31 05:55:37 EDT 2013


Serhiy Storchaka wrote:

> 30.05.13 23:46, Skip Montanaro написав(ла):
>> Am I missing something about how io.StringIO works?  I thought it was
>> a more-or-less drop-in replacement for StringIO.StringIO.
> 
> io.StringIO was backported from Python 3. It is a text (unicode) stream.
> cStringIO.StringIO is a binary stream and StringIO.StringIO can be used
> as binary or unicode stream depending on arguments. Use io.BaseIO as a

I think you mean io.BytesIO.

> replacement for StringIO.StringIO/cStringIO.StringIO if you need a
> binary stream.





More information about the Python-list mailing list