you can use command line redirection to make a file be sys.stdin:

python mySolution.py < A-small-attempt85.in > a.out

This will treat that in file as standard in and output to the out file.

Sent from my iPad

On 15 Apr 2013, at 06:27, wonjun <wonj...@gmail.com> wrote:

> Hello All,
> 
> I mainly code in Python, and is quite confused with the IO part. 
> Well I normally do the following for IO:
> 
> f = open('filename','r')
> a = f.read()
> b = a.split('\n')
> 
> Now, depending on the problem at hand, I use a for loop / while loop to look 
> over all cases and solve them accordingly. 
> I believe this is time consuming (when there is a very big input), and when I 
> download the solution, they all are written something like this:
> 
> (Code taken from the Analysis for Tic-Tac-Toe-Tomek)
> 
> numcases = int(sys.stdin.readline())
> for casenum in range(1,numcases+1):
>    board = []
>    for i in range(0,5):
>      board.append(sys.stdin.readline().strip())
>    print 'Case #' + repr(casenum) + ': ' + solve(board)
> 
> 
> 
> Now, when we run this code, we have to manually write down everything - and 
> then it will solve the problem. Is there a way to do it via command line to 
> solve everycase in one go?
> 
> And, is there any good material on Python IO which touches on stuff like 
> above?
> Thanks.
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Google Code Jam" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to google-code+unsubscr...@googlegroups.com.
> To post to this group, send email to google-code@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To post to this group, send email to google-code@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to