Created
April 24, 2012 12:28
-
-
Save miohtama/2479234 to your computer and use it in GitHub Desktop.
Wrap Python print statement to breakpoint when something prints by catching output
This file contains 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 sys | |
old_f = sys.stdout | |
BAD_OUTPUT = "hospitalArrival_dateTimeStrokeOnSet" | |
class F: | |
def write(self, x): | |
if x == BAD_OUTPUT: | |
import pdb ; pdb.set_trace() | |
old_f.write(x) | |
def writelines(self, lines): | |
old_f.writelines(lines) | |
def flush(self): | |
old_f.flush() | |
sys.stdout = F() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment