Back to Small Clever Rooms
RSS Feed


I recently discovered the StringIO module and have been using it surprisingly often. It’s not a terribly flashy module, being roughly equivalent to a C++ stringstream, but it is proving useful more than I expected. There are a couple use cases that have come up more than once just in the last couple weeks:

In retrospect, at least the second of these things seems obvious: like it should be a bog-standard way to write unit tests that don’t depend on external resources. But I’ve done a fair amount of cruising StackOverflow and other places looking at Python unit test best practices and haven’t ever stumbled across it before.

Contact me? My email is my first initial and last name at I'm also on Twitter as @valrus (mostly defunct) and Mastodon as @[email protected]