linecache
The linecache module allows you to randomly access any line of a text file.
For example, the next lines of code belong to the file c:\ temp\ interface.py.
import time, sys
name = raw_input("Enter your name: ")
print "Hi %s, how are you?" % name
feedback = raw_input("What do you want to do now? ")
print "I do not want to do that. Good bye!"
time.sleep(3)
sys.exit()
Check the result that is retrieved when the function
linecache.getline(file,linenumber) is called.
>>> import linecache
>>> print linecache.getline("c:\ \ temp\ interface.py",4)
feedback = raw_input("What do you want to do now? ")