''' linereader.py Jeff Ondich, 2013-01-04 Reads lines from a file, prints them in upper-case, and prints a count of the lines at the end. Intended as the Python half of parallel examples in Python and Java. See LineReader.java. ''' inputFilePath = 'somelines.txt' try: inputFile = open(inputFilePath) except Exception, e: print >>sys.stderr, 'Cannot open', inputFilePath exit() numberOfLines = 0 for line in inputFile: print line.upper(), numberOfLines += 1 print '\nNumber of lines:', numberOfLines