How to log python Shell results
kyosohma at gmail.com
kyosohma at gmail.com
Fri Aug 3 11:46:45 EDT 2007
On Aug 3, 10:14 am, Colly <colin.mcfarl... at cgi.com> wrote:
> How do I output the IDLE 1.2.1 Python Shell results to a log file.
Redirect stdout to the log file.
<code>
out = sys.stdout # save stdout for restoration later
f = open(r'c:\test\test.log', 'w')
sys.stdout = f # now stdout is redirected
# do some stuff that prints output
f.close() # when done, close the file
sys.stdout = out # restore stdout
</code>
Or you could just copy and paste it yourself.
Mike
More information about the Python-list
mailing list