Re: running a script with an input file

2008-07-21 Thread Fredrik Lundh

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:



prog_name.py input_file output_file

I get an EOF error.

What should I do to make this work?


Was that supposed to be

   prog_name.py input_file output_file

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

   http://www.ss64.com/ntsyntax/redirection.html

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.

/F

--
http://mail.python.org/mailman/listinfo/python-list


running a script with an input file

2008-07-20 Thread David Bikard
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:
prog_name.py input_file output_file

I get an EOF error.

What should I do to make this work?

Thx,
David
--
http://mail.python.org/mailman/listinfo/python-list