By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,957 Members | 1,960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,957 IT Pros & Developers. It's quick & easy.

How to log python Shell results

P: n/a
How do I output the IDLE 1.2.1 Python Shell results to a log file.

Aug 3 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.