Would something like this work? Extract most of your code into a new
function that expects arguments similar to the ones you send in via the
command line. Then write a new function that gathers the command line
arguments and sends them to the first function ...
def main(foo, bar):
a = foo + bar
foo, bar = get_command_line_args()
if __name__ == "__main__":
Then your other scripts can just call the main function.