I am using
myFile.write("...") often and sometimes I'd like to see the output in the console rather than re-opening the updated file. I am using IDLE.
So, I'd like to know, instead of going and replacing
print() everywhere, can I replace the filename (
output.txt) with something like STDIO when setting the myFile variable?
myFile = open("output.txt", "w")
Here you go: sys.stdout. Just use it like any other file handle. E.g.
print >> sys.stderr, "Hi! I'm an error!"
print ("Hi! I'm an error!",file=sys.stderr)mgilson 2012-04-04 02:16
stdin. Fixed that for you. ; - Li-aung Yip 2012-04-28 22:39