sys.stndout syntax
Bjorn Pettersen
bjorn at roguewave.com
Fri Aug 18 16:46:24 EDT 2000
Both at the same time:
class Echo:
def __init__(self, f):
self.f = open(f, 'w')
def write(self, txt):
self.f.write(txt)
sys.__stdout__.write(txt)
sys.stdout = Echo('file.txt')
print 'on screen, and on file...'
sys.stdout = sys.__stdout__
closing-the-file-left-as-an-excercise'ly y'rs
-- bjorn
"d. savitsky" wrote:
>
> greetings, very quick question.
>
> on win32, to get printed output to a file i use
> >>> sys.stndout = open('file.txt', 'w')
> how do i get it to go back to the command line, or better yet, how do i
> output to both at the same time?
>
> thanks
>
> doug
>
> --
> http://www.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list