tags:

views:

66

answers:

1

Besides the obvious (one is a type, the other a class)? What should be preferred? Any notable difference in use cases, perhaps?

+4  A: 

http://docs.python.org/library/io.html#io.StringIO

http://docs.python.org/library/stringio.html

I see this.

An in-memory stream for unicode text. It inherits TextIOWrapper.

This module implements a file-like class, StringIO, that reads and writes a string buffer (also known as memory files).

io.StringIO is a class. It handles Unicode. It reflects the preferred Python 3 library structure.

StringIO.StringIO is a class. It handles strings. It reflects the legacy Python 2 library structure.

What should be preferred?

Always move forward toward the new library organization. The io.open should be used to replace the built-in Unicode-unaware open.

Forward. Move forward.

S.Lott
@Alex Martelli. Good point. I was wrong and fixed it. Sometimes "string" means "bytes". Sometimes "string" means "string".
S.Lott