Skip to content

Instantly share code, notes, and snippets.

@polyvertex
Created February 7, 2015 09:58
Show Gist options
  • Save polyvertex/849135e0c46a26ea129f to your computer and use it in GitHub Desktop.
Save polyvertex/849135e0c46a26ea129f to your computer and use it in GitHub Desktop.
Unbuffered stream emulation in Python
class Unbuffered:
"""
Unbuffered stream emulation
Usage: sys.stdout = Unbuffered(sys.stdout)
"""
def __init__(self, stream):
self.stream = stream
def write(self, data):
self.stream.write(data)
self.stream.flush()
def __getattr__(self, attr):
return getattr(self.stream, attr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment