python command line arguments

This is how to make your python code, easier to use when called from command line.

import argparse

parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('integers', metavar='N', type=int, nargs='+',
                    help='an integer for the accumulator')
parser.add_argument('--sum', dest='accumulate', action='store_const',
                    const=sum, default=max,
                    help='sum the integers (default: find the max)')

args = parser.parse_args()
print args.accumulate(args.integers)

Make sure the params are entered

Nicest way I can see is

args = parser.parse_args()
if not (args.infile or args.call):
    parser.print_help()
    quit()