Created
February 7, 2015 09:58
-
-
Save polyvertex/849135e0c46a26ea129f to your computer and use it in GitHub Desktop.
Unbuffered stream emulation in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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