x = 99 y = "Hi" import sys sys.stdout = open('log.txt', 'a') # redirects prints to file print x, y, x # shows up in log.txt