I am playing with some programming challenges that will check the submission by:
python my_submission < in.txt > out.txt
When I try and make my submission, I want to read some cases/numbers/whatever from in.txt to see what is happening. Currently I am doing that by:
import sys
file = open('in.txt')
sys.stdin = file
for line in sys.stdin:
case1 = line.split()
some_function(case1)
So when I run my python program (hit cmd+B) in Sublime text, I can see whether I manage to read the input correctly, process one test case correctly, etc.... Then I just commend out the 2nd and 3rd line when my program should be submitted to the submission judge.
I was just wondering: is this the "preffered workflow" for dealing with this? Do pro programmers write some kind of unit test template function to do this?