Created
August 21, 2014 15:16
-
-
Save fulmicoton/b2422827f917502eb484 to your computer and use it in GitHub Desktop.
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
import csv | |
from contextlib import contextmanager | |
import sys | |
@contextmanager | |
def getstdin(): | |
try: | |
yield sys.stdin # process.stdout | |
print "a" | |
except Exception as e: | |
print "b", e | |
except GeneratorExit as e: | |
# generator exit is considered regular. | |
# it happens for with the timeout exception. | |
print "c" | |
finally: | |
print "d" | |
print "START" | |
with getstdin() as in_stream: | |
for row in csv.reader(in_stream, delimiter=","): | |
print row | |
print "DONE" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment