472,145 Members | 1,503 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

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 1800
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.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.