Skip to content

Instantly share code, notes, and snippets.

@kriskowal
Created April 9, 2009 21:49
Show Gist options
  • Save kriskowal/92762 to your computer and use it in GitHub Desktop.
Save kriskowal/92762 to your computer and use it in GitHub Desktop.
from StringIO import StringIO
buffer = StringIO()
buffer.write('Hello,')
buffer.write(' ')
buffer.write('World!')
assert buffer.getvalue() == 'Hello, World!'
buffer = StringIO(buffer.getvalue())
assert buffer.read(7) == "Hello, "
assert buffer.read() == "World!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment