# sumfunc1.py
# Written by Todd Wareham for CS 2500
"""
Given the name of a file of strings (all of which need not be integers) as 
 a command-line argument, computes and prints the total of all integers 
 in this file.
"""

import sys 

def getIntList(filename):
    intList = []
    for line in open(filename):
        for num in line.split():
            try:
                intList.append(int(num))
            except ValueError:
                pass
    return intList

def procFile(filename):
    return sum(getIntList(filename))



if len(sys.argv) != 2:
    print "usage: ", sys.argv[0], " filename"
    sys.exit(1)

sum = procFile(sys.argv[1])
print "sum = ", sum

