"collect command-line options in dictionarydef getopts(argv)opts {while argvif argv[ ][ ='-'opts[argv[ ]argv[ argv argv[ :elseargv argv[ :return opts if __name__ ='__main__'from sys import argv myargs getopts(argvif '-iin myargsprint(myargs['- ']print(myargsfind "-name valuepairs dict key is "-namearg example client code you might import and use such function in all your command-line tools when run by itselfthis file just prints the formatted argument dictionaryc:\pp \systempython testargv py { :\pp \systempython testargv py - data txt - results txt data txt {'- ''results txt''- ''data txt'naturallywe could get much more sophisticated here in terms of argument patternserror checkingand the like for more complex command lineswe could also use command-line processing tools in the python standard library to parse argumentsthe getopt modulemodeled after unix/ utility of the same name the optparse modulea newer alternativegenerally considered to be more powerful both of these are documented in python' library manualwhich also provides usage examples which we'll defer to here in the interest of space in generalthe more configurable your scriptsthe more you must invest in command-line processing logic complexity executable scripts on unix unix and linux usersyou can also make text files of python source code directly executable by adding special line at the top with the path to the python interpreter and giving the file executable permission for instancetype this code into text file called myscript#!/usr/bin/python print('and nice red uniforms' script execution context