I currently have a python file that uses sys.argv [1] to accept a line on the command line. Then it performs operations on this line and then returns the modified line to the command line.
I would like to implement a batch mode parameter in which I can provide a string file (one per line, fwiw) and return it to the command line so that I can redirect the output by doing something like
$ python script.py -someflag file.txt > modified.txt
while maintaining current capabilities.
I use only 2.6, so argparse is not an option. The tutorials I saw either use argparse, getopt, or delve into examples that are too complex / not applicable.
What is the best way to check input and act accordingly?
source
share