I am using Python 2.4 on Windows.
I'm trying to save the contents of the debug window. I managed to redirect all print statements so that it prints on the debug window as well as saves a copy into a text file. The code is shpwn below:
import sys import string open('C:\Users\djeganat\Desktop\\todo.txt', 'w').close() class RedirectOutput: def __init__(self, stdout): self.stdout = stdout def write(self, s): self.stdout.write(s) f = open('C:\Users\djeganat\Desktop\\todo.txt', 'a') f.write(s) f.close() # redirect standard output sys.stdout = RedirectOutput(sys.stdout) print "abcd", print "\n xyz" var = raw_input("Enter something: ")
This works perfectly fine but does not save the user input. I understand that in order to do this I need to redirect stdin. But, I don't seem to be doing it right. Could you show me?