def write(self, s):
    self.stdout.write('Writing %r\n' % s)
traceback.print_stack(file=self.stdout)
sys.stdout = TracePrints()

def a():
    print('I am here')

def b():
    a()
b()
Поиск оператора печати в Python