469,641 Members | 1,195 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,641 developers. It's quick & easy.

How to log python Shell results

How do I output the IDLE 1.2.1 Python Shell results to a log file.

Aug 3 '07 #1
1 1734
On Aug 3, 10:14 am, Colly <colin.mcfarl...@cgi.comwrote:
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

Aug 3 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

54 posts views Thread by Brandon J. Van Every | last post: by
4 posts views Thread by vagrantbrad | last post: by
16 posts views Thread by John Salerno | last post: by
12 posts views Thread by Krypto | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.