# CountLines.py - Illustrate file input. # Ask the user for name of input file, and we'll # count the lines. # For more information, see section 7.2 of the Python Tutorial # in the ActivePython 2.6 Documentation fileName = raw_input("What is the name of the file?") file = open(fileName, "r") count = 0 for line in file: count += 1 file.close() print "I saw " + str(count) + " lines"