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

Re: running a script with an input file

P: n/a
David Bikard wrote:
I'd like to run a program so that it reads the input() or raw_input()
statements from an input file instead of
reading from keyboard. I'd also like it to write the print statements in
an output file rather than on the screen.

I'm on windows XP and when I run: input_file output_file

I get an EOF error.

What should I do to make this work?
Was that supposed to be <input_file >output_file

? (< and does i/o redirection; random google link:

If you want to do the same thing from inside the program, you can do:

import sys

sys.stdin = open("input_file")
sys.stdout = open("output_file", "w")

before you start reading or writing stuff.


Jul 21 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.