class MyStream(object):

    def __init__(self, target):
        self.target = target

def write(self, text):
    if text.strip():
        record = Record(*inspect.getouterframes(inspect.currentframe())[1])
self.target.write('{f} {n}: '.format(f=record.filename, n=record.line_number))
self.target.write(text)
sys.stdout = MyStream(sys.stdout)

def foo():
    print('Hi')
foo()
How do you find where a print statement is located?