Redirect stdout to file
Gaetan Corneau
Gaetan_Corneau at baan.com
Wed Jul 14 14:16:20 EDT 1999
Frederik,
I tried it and tought it didn't work, but it seems it was my fault. I did it
this way:
from sys import stdout
stdout = open("out.txt", "w")
I changed to:
import sys
sys.stdout = open("out.txt", "w")
and it worked. Do you know why?
Thanks a lot for your help!
______________________________________________________
Gaetan Corneau
Software Developer (System integration Team)
BaaN Supply Chain Solutions
E-mail: Gaetan_Corneau at baan.com
Compuserve: Gaetan_Corneau at compuserve.com
ICQ Number: 7395494
Tel: (418) 266-8252
______________________________________________________
"Profanity is the one language all programmers know best"
-----Original Message-----
From: Fredrik Lundh [mailto:fredrik at pythonware.com]
Sent: Wednesday, July 14, 1999 2:04 PM
To: Gaetan Corneau
Cc: Python Mailing List
Subject: Re: Redirect stdout to file
Gaetan Corneau <Gaetan_Corneau at baan.com> wrote:
> I'm in Barneveld Holland right now (hey, maybe I'll go visit the famous
> Stichting Mathematisch Centrum ;) and I would like to redirect output from
> the print statement to a text file. I think a saw a message about that
some
> time ago, but I can't find it right now.
try this:
import sys
sys.stdout = open("my.log", "w")
print "this ends up in the logg file"
also see: http://www.python.org/doc/FAQ.html#5.8
</F>
More information about the Python-list
mailing list