wc2.py

punctuation = ".,-{}[]()?!:"

def word_count(f):
	count = 0
	for line in f:
		for word in line.split():
			if word.strip(punctuation):
				count += 1
	return count

if __name__ == "__main__":
	filename = "../bee.txt"
	with open(filename) as f:
		print("%s: %d words" % (filename, word_count(f)))