[Tutor] Read from large text file, parse, find string, print string + line number to second text file.

Scurvy Scott etanes.rm at gmail.com
Fri Feb 1 22:24:31 CET 2013


One last question on this topic..

I'd like to call the files and the string form the command line like

Python whatever.py STRINGTOSEARCH NEWFILE FILETOOPEN

My understanding is that it would be accomplished as such

import sys

myString = sys.argv[1]
filetoopen = sys.argv[2]
newfile = sys.argv[3]


ETC ETC CODE HERE

Is this correct/pythonic? Is there a more recommended way? Am I retarded?

Thanks again in advance,
Scott


More information about the Tutor mailing list