Next / Previous / Contents / Shipman's homepage

6.3. main(): Main procedure

The main iterates over the command line arguments. As a courtesy to undertrained users, we complain if there are no arguments at all. Each puzzle file name in turn is sent to Section 6.6, “solveFile(): Solve one puzzle” for solution.

sudoku
# - - -   m a i n   - - -

def main():
    """sudoku main program
    """

    #-- 1 --
    argList  =  sys.argv[1:]

    #-- 2 --
    # [ if argList is empty ->
    #     sys.stderr  +:=  error message
    #   else ->
    #     sys.stdout  +:=  solutions to valid puzzles named in
    #         argList
    #     sys.stderr  +:=  error messages about invalid puzzles
    #         named in argList ]
    if  len(argList) == 0:
        message ( "*** You must supply names of "
            "at least one sudoku puzzle file.\n" )
    else:
        for  arg in argList:
            solveFile ( arg )