from os import path
import fileinput

result = []
filename = None

for test in fileinput.input(): #open command line arguments as files or 
read from stdin, check documentation
    if fileinput.isfirstline(): #skip first line with total lines number
        filename = fileinput.filename()
    else:
        #here goes your rocket science
        r = 'test result'
        s = "Case #%d: %s\n" % (fileinput.lineno()-1, r)
        result.append(s)

with open(''.join((path.splitext(filename)[0], '.out')), 'w') as f:
    #write result into file with the same name, but different extension
    f.writelines(result)

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-code/-/ghLJjsKdh-YJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to