and put it in directory on the module search pathwe can use it any time we need to step through file line by line example - is client script that does simple line translations example - pp \system\filetools\commands py #!/usr/local/bin/python from sys import argv from scanfile import scanner class unknowncommand(exception)pass def processline(line)if line[ ='*'print("ms "line[ :- ]elif line[ ='+'print("mr "line[ :- ]elseraise unknowncommand(linefilename 'data txtif len(argv= filename argv[ scanner(filenameprocesslinedefine function applied to each line strip first and last char\ raise an exception allow filename cmd arg start the scanner the text file hillbillies txt contains the following lines*granny +jethro *elly may +"uncle jedand our commands script could be run as followsc:\pp \system\filetoolspython commands py hillbillies txt ms granny mr jethro ms elly may mr "uncle jedthis worksbut there are variety of coding alternatives for both filessome of which may be better than those listed above for instancewe could also code the command processor of example - in the following wayespecially if the number of command options starts to become largesuch data-driven approach may be more concise and easier to maintain than large if statement with essentially redundant actions (if you ever have to change the way output lines printyou'll have to change it in only one place with this form)commands {'*''ms ''+''mr 'data is easier to expand than codedef processline(line)tryprint(commands[line[ ]]line[ :- ]except keyerrorraise unknowncommand(linefile tools